Skip to content

Commit 69afac1

Browse files
committed
Rewrite isJailbroken to use dispatch_once
1 parent d41c638 commit 69afac1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Sources/KSCrashRecording/Monitors/KSCrashMonitor_System.m

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,12 @@ static uint64_t usableMemory(void)
292292
*/
293293
static inline bool isJailbroken(void)
294294
{
295-
static bool initialized_jb;
296-
static bool is_jb;
297-
if (!initialized_jb) {
298-
get_jailbreak_status(&is_jb);
299-
initialized_jb = true;
300-
}
301-
302-
return is_jb;
295+
static bool is_jailbroken;
296+
static dispatch_once_t onceToken;
297+
dispatch_once(&onceToken, ^{
298+
get_jailbreak_status(&is_jailbroken);
299+
});
300+
return is_jailbroken;
303301
}
304302

305303
/** Check if the current build is a debug build.

0 commit comments

Comments
 (0)