Skip to content

Commit 1ac7481

Browse files
committed
[Images] Bail out when GIF data is in unexpected format instead of crashing
Summary: When the GIF data is not a string nor NSData, `imageSource` is some unknown value set to whatever memory was on the stack. Calling `CGImageSourceGetType` on it has undefined behavior, and if it makes through to the CFRelease (maybe because it is NULL) then CFRelease will crash. This fixes a clang warning. Closes facebook#77 Github Author: James Ide <ide@jameside.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
1 parent 9d884a2 commit 1ac7481

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ReactKit/Base/RCTConvert.m

+3
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ + (CAKeyframeAnimation *)GIF:(id)json
446446
}
447447

448448
imageSource = CGImageSourceCreateWithData((CFDataRef)data, NULL);
449+
} else {
450+
RCTLogMustFix(@"Expected NSString or NSData for GIF, received %@: %@", [json class], json);
451+
return nil;
449452
}
450453

451454
if (!UTTypeConformsTo(CGImageSourceGetType(imageSource), kUTTypeGIF)) {

0 commit comments

Comments
 (0)