Cleanup before exit on error

This commit is contained in:
William Robinet 2021-01-27 18:30:28 +01:00
parent b3316bb5fd
commit 2a7b0f664f

View file

@ -104,6 +104,7 @@ int err_exit(str,num)
int num; int num;
{ {
fprintf(stderr,"ERROR: %s\n",str); fprintf(stderr,"ERROR: %s\n",str);
sig_handler(SIGQUIT);
exit(num); exit(num);
} }
@ -130,6 +131,8 @@ pcap_t *p;
proto_mod *mod=&ssl_mod; proto_mod *mod=&ssl_mod;
n_handler *n; n_handler *n;
char *interface_name=0; char *interface_name=0;
char *file=0;
char *filter=0;
void sig_handler(int sig) void sig_handler(int sig)
{ {
int freed_conn = 0; int freed_conn = 0;
@ -147,8 +150,12 @@ void sig_handler(int sig)
pcap_close(p); pcap_close(p);
if(interface_name) if(interface_name)
free(interface_name); free(interface_name);
if(filter)
free(filter);
if(file)
free(file);
exit(0); exit(sig);
} }
void pcap_cb(ptr,hdr,data) void pcap_cb(ptr,hdr,data)
@ -309,8 +316,6 @@ int main(argc,argv)
extern int optind; extern int optind;
#endif #endif
pcap_if_t *interfaces; pcap_if_t *interfaces;
char *file=0;
char *filter=0;
bpf_u_int32 localnet,netmask; bpf_u_int32 localnet,netmask;
int c; int c;
module_def *m=0; module_def *m=0;