]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/mpm: prevents double free
authorPhilippe Antoine <pantoine@oisf.net>
Fri, 18 Apr 2025 12:38:48 +0000 (14:38 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 19 Apr 2025 08:35:05 +0000 (10:35 +0200)
CID: 1645545

PatternDatabaseGetCached frees cd on success
So, we should NULL it, so that in case PatternDatabaseGetSize fails
and we goto error, we do not free cd again.

src/util-mpm-hs.c

index 4a7fed2a0b5e03b999c22e1e9bd84022de9c3904..a738a691c3e2539c416e88c2dc217288ed83e00b 100644 (file)
@@ -787,6 +787,7 @@ int SCHSPreparePatterns(MpmConfig *mpm_conf, MpmCtx *mpm_ctx)
 
     const char *cache_path = pd->no_cache || !mpm_conf ? NULL : mpm_conf->cache_dir_path;
     if (PatternDatabaseGetCached(&pd, cd, cache_path) == 0 && pd != NULL) {
+        cd = NULL;
         ctx->pattern_db = pd;
         if (PatternDatabaseGetSize(pd, &ctx->hs_db_size) != 0) {
             SCMutexUnlock(&g_db_table_mutex);