Check binary->code existence before destroying (#2979)

Fixes #2975
This commit is contained in:
Ryan Harrison 2019-10-17 12:30:15 -04:00 committed by GitHub
parent 9c0ae6bb8e
commit 024417d836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -781,9 +781,10 @@ spv_result_t spvBinaryParse(const spv_const_context context, void* user_data,
// TODO(dneto): This probably belongs in text.cpp since that's the only place
// that a spv_binary_t value is created.
void spvBinaryDestroy(spv_binary binary) {
if (!binary) return;
delete[] binary->code;
delete binary;
if (binary) {
if (binary->code) delete[] binary->code;
delete binary;
}
}
size_t spv_strnlen_s(const char* str, size_t strsz) {