ref: 1013d96cfe9cab16f66c31745700d257e777cfef
parent: 350617f55d9154f2e95d65687a0a719483d745a7
author: Ralph Giles <giles@thaumas.net>
date: Mon Jan 16 06:00:14 EST 2017
opusrtp::sniff() - Call pcap_close for any error condition. This avoids leaking the handle on error.
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -878,6 +878,7 @@
params = malloc(sizeof(state));
if (!params) {
fprintf(stderr, "Couldn't allocate param struct.\n");
+ pcap_close(pcap);
return -1;
}
params->linktype = pcap_datalink(pcap);
@@ -885,6 +886,7 @@
if (!params->stream) {
fprintf(stderr, "Couldn't allocate stream struct.\n");
free(params);
+ pcap_close(pcap);
return -1;
}
if (ogg_stream_init(params->stream, rand()) < 0) {
@@ -891,6 +893,7 @@
fprintf(stderr, "Couldn't initialize Ogg stream state.\n");
free(params->stream);
free(params);
+ pcap_close(pcap);
return -1;
}
params->out = fopen("rtpdump.opus", "wb");
@@ -898,6 +901,7 @@
fprintf(stderr, "Couldn't open output file.\n");
free(params->stream);
free(params);
+ pcap_close(pcap);
return -2;
}
params->seq = 0;