Skip to content

Commit f522cab

Browse files
committed
Merge pull request #408 from libgit2/fix-strarray-bridging
Don’t try to add `nil` strings to an array.
2 parents a897d3d + 7187cd8 commit f522cab

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Classes/Categories/NSArray+StringArray.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ + (instancetype)git_arrayWithStrarray:(git_strarray)strarray {
2222
const char *cStr = strarray.strings[i];
2323
if (cStr == NULL) continue;
2424

25-
strings[stringsCount++] = @(cStr);
25+
NSUInteger length = strlen(cStr);
26+
NSString *string =
27+
[[NSString alloc] initWithBytes:cStr length:length encoding:NSUTF8StringEncoding]
28+
?: [[NSString alloc] initWithBytes:cStr length:length encoding:NSASCIIStringEncoding];
29+
if (string == nil) continue;
30+
31+
strings[stringsCount++] = string;
2632
}
2733

2834
@onExit {

0 commit comments

Comments
 (0)