Skip to content

Commit

Permalink
Scratch: fix scratch free issue when memory allocation fails
Browse files Browse the repository at this point in the history
Fixes github issue intel#174
  • Loading branch information
xiangwang1 authored and fatchanghao committed Aug 13, 2019
1 parent 1775373 commit 4959283
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4959283

Please sign in to comment.