bpf: close fp in all error paths

pull/9472/head
Victor Julien 3 years ago
parent 161aaefb69
commit e66c63b2ea

@ -528,6 +528,7 @@ static void SetBpfStringFromFile(char *filename)
if (SCFstatFn(fileno(fp), &st) != 0) {
SCLogError(SC_ERR_FOPEN, "Failed to stat file %s", filename);
fclose(fp);
exit(EXIT_FAILURE);
}
bpf_len = st.st_size + 1;
@ -535,6 +536,7 @@ static void SetBpfStringFromFile(char *filename)
bpf_filter = SCMalloc(bpf_len * sizeof(char));
if (unlikely(bpf_filter == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate buffer for bpf filter in file %s", filename);
fclose(fp);
exit(EXIT_FAILURE);
}
memset(bpf_filter, 0x00, bpf_len);

Loading…
Cancel
Save