mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-10 01:15:00 +08:00
Check return code from malloc (#20173)
Summary: Calls abort() in cases where malloc returns NULL. Checking the return value from malloc is good practice and is required to pass a [Veracode security scan](https://www.veracode.com/). This will let developers who are required to submit their software to Veracode use React Native. Pull Request resolved: https://github.com/facebook/react-native/pull/20173 Differential Revision: D9235096 Pulled By: hramos fbshipit-source-id: 9fdc97f9e84f8d4d91ae59242093907f7a81d286
This commit is contained in:
committed by
Facebook Github Bot
parent
03663491c6
commit
b21d4914de
@@ -302,6 +302,12 @@ RCT_EXTERN_C_END
|
||||
|
||||
[argumentBlocks addObject:^(__unused RCTBridge *bridge, NSUInteger index, id json) {
|
||||
void *returnValue = malloc(typeSignature.methodReturnLength);
|
||||
if (!returnValue) {
|
||||
// CWE - 391 : Unchecked error condition
|
||||
// https://www.cvedetails.com/cwe-details/391/Unchecked-Error-Condition.html
|
||||
// https://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c
|
||||
abort();
|
||||
}
|
||||
[typeInvocation setArgument:&json atIndex:2];
|
||||
[typeInvocation invoke];
|
||||
[typeInvocation getReturnValue:returnValue];
|
||||
|
||||
Reference in New Issue
Block a user