]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mime-decode: fix minor memory leak if Mime parser initialization were to fail.
authorTom DeCanio <decanio.tom@gmail.com>
Thu, 9 Oct 2014 19:52:30 +0000 (12:52 -0700)
committerVictor Julien <victor@inliniac.net>
Thu, 30 Oct 2014 12:33:54 +0000 (13:33 +0100)
src/mime-decode.c

index a1f8b226ca9faa7bb8f621483771ee412893c260..6d34d0f6f8a595c4f17af4b29099202e190fa31d 100644 (file)
@@ -2349,6 +2349,7 @@ MimeDecParseState * MimeDecInitParser(void *data,
     state->stack = SCMalloc(sizeof(MimeDecStack));
     if (unlikely(state->stack == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed");
+        SCFree(state);
         return NULL;
     }
     memset(state->stack, 0x00, sizeof(MimeDecStack));
@@ -2356,6 +2357,8 @@ MimeDecParseState * MimeDecInitParser(void *data,
     mimeMsg = SCMalloc(sizeof(MimeDecEntity));
     if (unlikely(mimeMsg == NULL)) {
         SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed");
+        SCFree(state->stack);
+        SCFree(state);
         return NULL;
     }
     memset(mimeMsg, 0x00, sizeof(MimeDecEntity));
@@ -2366,6 +2369,8 @@ MimeDecParseState * MimeDecInitParser(void *data,
     PushStack(state->stack);
     if (state->stack->top == NULL) {
         SCLogError(SC_ERR_MEM_ALLOC, "memory allocation failed");
+        SCFree(state->stack);
+        SCFree(state);
         return NULL;
     }
     state->stack->top->data = mimeMsg;