mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 09:21:44 +08:00
Close RAM bundle as soon as we read the magic number
Summary: No need to keep it open; it just makes it harder to reason about error handling. Reviewed By: majak Differential Revision: D3518200 fbshipit-source-id: dc1af6eb0f75de7e9f73513ed1dd522048f76670
This commit is contained in:
committed by
Facebook Github Bot 2
parent
5323b77fba
commit
b3ac5f06d2
@@ -56,8 +56,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
}
|
||||
|
||||
uint32_t magicNumber;
|
||||
if (fread(&magicNumber, sizeof(magicNumber), 1, bundle) != 1) {
|
||||
fclose(bundle);
|
||||
size_t readResult = fread(&magicNumber, sizeof(magicNumber), 1, bundle);
|
||||
fclose(bundle);
|
||||
if (readResult != 1) {
|
||||
onComplete(RCTErrorWithMessage(@"Error reading bundle"), source, 0);
|
||||
return;
|
||||
}
|
||||
@@ -81,7 +82,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
sourceLength = source.length;
|
||||
}
|
||||
|
||||
fclose(bundle);
|
||||
onComplete(error, source, sourceLength);
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user