From b955ca7b867d0f7d45a365526c1fc568ea50cc5f Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 18 Dec 2013 12:23:50 +0100 Subject: [PATCH] conf: fix potential use-after-free on error Coverity 1139544 If strdup would fail, 'node' was freed but it wasn't set to NULL. The code then returned node. The caller would not detect there was an error and use the freed pointer. --- src/conf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conf.c b/src/conf.c index 104f92ad06..cabde9e36f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -91,6 +91,7 @@ ConfGetNodeOrCreate(char *name, int final) node->name = SCStrdup(key); if (unlikely(node->name == NULL)) { ConfNodeFree(node); + node = NULL; SCLogWarning(SC_ERR_MEM_ALLOC, "Failed to allocate memory for configuration."); goto end; -- 2.47.2