diff --git a/src/counters.c b/src/counters.c index fccf0ed683..ea92d10b43 100644 --- a/src/counters.c +++ b/src/counters.c @@ -48,6 +48,7 @@ static char *SCPerfGetLogFilename(void) if (snprintf(log_filename, PATH_MAX, "%s/%s", log_dir, SC_PERF_DEFAULT_LOG_FILENAME) < 0) { SCLogError(SC_SPRINTF_ERROR, "Sprintf Error"); + free(log_filename); return NULL; } @@ -1185,11 +1186,6 @@ SCPerfCounterArray *SCPerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id, return NULL; } - if (pctx == NULL) { - SCLogDebug("perfcontext is NULL"); - return NULL; - } - if ( (pca = malloc(sizeof(SCPerfCounterArray))) == NULL) { SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); exit(EXIT_FAILURE); diff --git a/src/defrag.c b/src/defrag.c index 51ffd1efb6..d58475cde7 100644 --- a/src/defrag.c +++ b/src/defrag.c @@ -347,8 +347,10 @@ DefragTrackerNew(void *arg) tracker = calloc(1, sizeof(*tracker)); if (tracker == NULL) return NULL; - if (SCMutexInit(&tracker->lock, NULL) != 0) + if (SCMutexInit(&tracker->lock, NULL) != 0) { + free(tracker); return NULL; + } tracker->dc = dc; TAILQ_INIT(&tracker->frags); @@ -387,7 +389,7 @@ DefragContextNew(void) /* Initialize the hash table. */ dc->frag_table = HashListTableInit(DEFAULT_DEFRAG_HASH_SIZE, DefragHashFunc, DefragHashCompare, DefragHashFree); - if (dc == NULL) { + if (dc->frag_table == NULL) { SCLogError(SC_ERR_MEM_ALLOC, "Defrag: Failed to initialize hash table."); exit(EXIT_FAILURE); diff --git a/src/log-httplog.c b/src/log-httplog.c index 95a8e40b37..ac2395f2f1 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -192,6 +192,7 @@ TmEcode LogHttpLogThreadInit(ThreadVars *t, void *initdata, void **data) if(initdata == NULL) { SCLogDebug("Error getting context for HTTPLog. \"initdata\" argument NULL"); + free(aft); return TM_ECODE_FAILED; } /** Use the Ouptut Context (file pointer and mutex) */ diff --git a/src/source-pcap-file.c b/src/source-pcap-file.c index 8ffa75bcb4..75a762386f 100644 --- a/src/source-pcap-file.c +++ b/src/source-pcap-file.c @@ -150,6 +150,7 @@ TmEcode ReceivePcapFileThreadInit(ThreadVars *tv, void *initdata, void **data) { default: printf("Error: datalink type %" PRId32 " not yet supported in module PcapFile.\n", pcap_g.datalink); + free(ptv); return TM_ECODE_FAILED; } diff --git a/src/util-unittest-helper.c b/src/util-unittest-helper.c index 3774157b04..7d54a18344 100644 --- a/src/util-unittest-helper.c +++ b/src/util-unittest-helper.c @@ -149,6 +149,7 @@ Packet **UTHBuildPacketArrayFromEth(uint8_t *raw_eth[], int *pktsize, int numpkt p[i] = malloc(sizeof(Packet)); if (p[i] == NULL) { SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for a packet of the array"); + free(p); return NULL; } memset(p[i], 0, sizeof(Packet));