log/pcap: work around scan-build fp

log-pcap.c:1008:24: warning: Use of memory after it is freed [unix.Malloc]
            if (remove(pf->filename) != 0) {
                       ^~~~~~~~~~~~
1 warning generated.
pull/8762/head
Victor Julien 3 years ago
parent fc000a6d81
commit 0af599f5fa

@ -1004,14 +1004,16 @@ static TmEcode PcapLogInitRingBuffer(PcapLogData *pl)
if (pl->file_cnt > pl->max_files) {
PcapFileName *pf = TAILQ_FIRST(&pl->pcap_file_list);
while (pf != NULL && pl->file_cnt > pl->max_files) {
TAILQ_REMOVE(&pl->pcap_file_list, pf, next);
SCLogDebug("Removing PCAP file %s", pf->filename);
if (remove(pf->filename) != 0) {
SCLogWarning("Failed to remove PCAP file %s: %s", pf->filename, strerror(errno));
}
TAILQ_REMOVE(&pl->pcap_file_list, pf, next);
PcapFileNameFree(pf);
pf = TAILQ_FIRST(&pl->pcap_file_list);
pl->file_cnt--;
pf = TAILQ_FIRST(&pl->pcap_file_list);
}
}

Loading…
Cancel
Save