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.
pull/730/head
Victor Julien 12 years ago
parent 3714925d2b
commit b955ca7b86

@ -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;

Loading…
Cancel
Save