[React Native] Fix crash if current queue has no label
Summary: If the current queue has no label, `dispatch_queue_get_label()` returns `NULL` and `@((char *)0)` will crash the app. Closes facebook#1833
This commit is contained in:
parent
88cfc1aaa6
commit
4fdeed0214
|
@ -78,7 +78,12 @@ NSString *RCTCurrentThreadName(void)
|
|||
#if DEBUG // This is DEBUG not RCT_DEBUG because it *really* must not ship in RC
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
threadName = @(dispatch_queue_get_label(dispatch_get_current_queue()));
|
||||
const char *label = dispatch_queue_get_label(dispatch_get_current_queue());
|
||||
if (label && strlen(label) > 0) {
|
||||
threadName = @(label);
|
||||
} else {
|
||||
threadName = [NSString stringWithFormat:@"%p", thread];
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
#else
|
||||
threadName = [NSString stringWithFormat:@"%p", thread];
|
||||
|
|
Loading…
Reference in New Issue