Skip to content

Commit

Permalink
[Images] Bail out when GIF data is in unexpected format instead of cr…
Browse files Browse the repository at this point in the history
…ashing

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.
  • Loading branch information
ide committed Feb 26, 2015
1 parent 96312af commit d0d774d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ReactKit/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ + (CAKeyframeAnimation *)GIF:(id)json
}

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

if (!UTTypeConformsTo(CGImageSourceGetType(imageSource), kUTTypeGIF)) {
Expand Down

0 comments on commit d0d774d

Please sign in to comment.