Scratch: fix scratch free issue when memory allocation fails

Fixes github issue #174
This commit is contained in:
Wang, Xiang W 2019-07-09 20:18:42 -04:00 committed by Chang, Harry
parent 177537313a
commit 49592833a7

View File

@ -279,7 +279,9 @@ hs_error_t HS_CDECL hs_alloc_scratch(const hs_database_t *db,
hs_error_t proto_ret = hs_check_alloc(proto_tmp);
if (proto_ret != HS_SUCCESS) {
hs_scratch_free(proto_tmp);
hs_scratch_free(*scratch);
if (*scratch) {
hs_scratch_free((*scratch)->scratch_alloc);
}
*scratch = NULL;
return proto_ret;
}