mirror of https://github.com/OISF/suricata
log-pcap.c: fix resource leak found by coverity
Goto the failure label instead of returning which will allow the open
directory to get cleaned up.
Fixes:
*** CID 1394675: Resource leaks (RESOURCE_LEAK)
/src/log-pcap.c: 615 in PcapLogInitRingBuffer()
609 * failure as the file might just not be a pcap log file. */
610 continue;
611 }
612
613 PcapFileName *pf = SCCalloc(sizeof(*pf), 1);
614 if (unlikely(pf == NULL)) {
>>> CID 1394675: Resource leaks (RESOURCE_LEAK)
>>> Variable "dir" going out of scope leaks the storage it points to.
615 return TM_ECODE_FAILED;
616 }
617 char path[PATH_MAX];
618 snprintf(path, PATH_MAX - 1, "%s/%s", pattern, entry->d_name);
619 if ((pf->filename = SCStrdup(path)) == NULL) {
620 goto fail;
This also means that pf can be NULL which should clear up CID
1394676 (REVERSE_INULL).
pull/2428/head
parent
0c6c9784a2
commit
553f7ec290
Loading…
Reference in New Issue