From 9dac5ec23cf1edeab607d98aeadc67e0ef058621 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 18 Apr 2025 14:38:48 +0200 Subject: [PATCH] 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. --- src/util-mpm-hs.c | 1 + 1 file changed, 1 insertion(+) 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); -- 2.47.2