[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:
Alex Akers 2015-07-03 02:03:33 -07:00
parent 88cfc1aaa6
commit 4fdeed0214
1 changed files with 6 additions and 1 deletions

View File

@ -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];