From e5994deb23296254e285471103065bf875bfbf1e Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Mon, 3 Nov 2025 10:24:48 +0530 Subject: [PATCH] util/varname: check id before unregister In case of an error a varname id is set to 0. Ideally, it shouldn't be found in the hash table lookup but add a check anyway to avoid obtaining the mutex lock and performing the lookup. --- src/util-var-name.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util-var-name.c b/src/util-var-name.c index a81920f351..a24c9f4874 100644 --- a/src/util-var-name.c +++ b/src/util-var-name.c @@ -203,6 +203,10 @@ const char *VarNameStoreSetupLookup(const uint32_t id, const enum VarTypes type) void VarNameStoreUnregister(const uint32_t id, const enum VarTypes type) { + if (unlikely(id == 0)) { + /* There was an error registering the varname, so nothing to unregister */ + return; + } SCMutexLock(&base_lock); VariableName lookup = { .type = type, .id = id }; VariableName *found = (VariableName *)HashListTableLookup(base.ids, (void *)&lookup, 0);