From: Eric Leblond Date: Fri, 18 Mar 2016 08:28:58 +0000 (+0100) Subject: output-json-email: fix memleak in error path X-Git-Tag: suricata-3.0.1RC1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dec6d933fb36a939288873e68dd09d2d72e19d7;p=thirdparty%2Fsuricata.git output-json-email: fix memleak in error path In JsonEmailLogJsonData function, an invalid state was leading to early exit without a proper freeing of resources. This should fix: Indirect leak of 72 byte(s) in 1 object(s) allocated from: #0 0x4c264b in malloc (/home/victor/qa/buildbot/donkey/z600fuzz/Private/src/.libs/lt-suricata+0x4c264b) #1 0x7fb09c1e886a in json_object (/usr/lib/x86_64-linux-gnu/libjansson.so.4+0x686a) #2 0xd6a272 in JsonEmailLogJson /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/output-json-email-common.c:370:19 #3 0xd956b9 in JsonSmtpLogger /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/output-json-smtp.c:103:9 #4 0xdcedac in OutputTxLog /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/output-tx.c:165:17 #5 0xff6669 in TmThreadsSlotVarRun /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/tm-threads.c:132:17 #6 0xffecc1 in TmThreadsSlotVar /home/victor/qa/buildbot/donkey/z600fuzz/Private/src/tm-threads.c:474:17 #7 0x7fb09bfcc181 in start_thread /build/eglibc-3GlaMS/eglibc-2.19/nptl/pthread_create.c:312 --- diff --git a/src/output-json-email-common.c b/src/output-json-email-common.c index b2750490d0..7ab9e727b0 100644 --- a/src/output-json-email-common.c +++ b/src/output-json-email-common.c @@ -263,6 +263,7 @@ json_t *JsonEmailLogJsonData(const Flow *f, void *state, void *vtx, uint64_t tx_ } if ((mime_state != NULL)) { if (entity == NULL) { + json_decref(sjs); SCReturnPtr(NULL, "json_t"); }