Add NULL checks for malloc in NXP BLE and S200 crypto
Site 1: src/platform/nxp/common/ble/BLEManagerCommon.cpp:1382
adv_data = (gapAdStructure_t *) malloc(...);
adv_data[0].length = ...; // ← NULL deref on OOM
Site 2: [src/platform/nxp/common/crypto/S200/CHIPCryptoPalS200.cpp:364-368
node = (sha256_node *) malloc(sizeof(...)); // ← unchecked
node->data = (uint8_t *) malloc(...); // ← unchecked, also leaks node on OOM
memcpy(node->data, ...); // ← second NULL deref
Fix template (both sites): standard NULL-check pattern:
adv_data = (gapAdStructure_t *) malloc(size);
VerifyOrReturnError(adv_data != nullptr, CHIP_ERROR_NO_MEMORY);
// ... use adv_data
For site 2, also fix the leak on the second malloc failure:
node->data = (uint8_t *) malloc(...);
if (node->data == nullptr) {
free(node);
return CHIP_ERROR_NO_MEMORY;
}
Add NULL checks for malloc in NXP BLE and S200 crypto
Site 1: src/platform/nxp/common/ble/BLEManagerCommon.cpp:1382
Site 2: [src/platform/nxp/common/crypto/S200/CHIPCryptoPalS200.cpp:364-368
Fix template (both sites): standard NULL-check pattern:
For site 2, also fix the leak on the second
mallocfailure: