From: Philippe Antoine Date: Fri, 18 Apr 2025 12:38:48 +0000 (+0200) Subject: util/mpm: prevents double free X-Git-Tag: suricata-8.0.0-rc1~453 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dac5ec23cf1edeab607d98aeadc67e0ef058621;p=thirdparty%2Fsuricata.git util/mpm: prevents double free 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. --- diff --git a/src/util-mpm-hs.c b/src/util-mpm-hs.c index 4a7fed2a0b..a738a691c3 100644 --- a/src/util-mpm-hs.c +++ b/src/util-mpm-hs.c @@ -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);