]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Scratch: fix scratch free issue when memory allocation fails
authorWang, Xiang W <xiang.w.wang@intel.com>
Wed, 10 Jul 2019 00:18:42 +0000 (20:18 -0400)
committerChang, Harry <harry.chang@intel.com>
Tue, 13 Aug 2019 06:52:21 +0000 (14:52 +0800)
Fixes github issue #174

src/scratch.c

index b46306406c0e2c072b1db8d98928340b1e52ecf4..25991e2bbad481ba52926742d95b9ce351007887 100644 (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;
     }