Skip to content

Commit bacb032

Browse files
authored
Merge pull request #279 from btriller/mem-cleanup
Cleanup allocated memory
2 parents 9e9cb6c + 3aae016 commit bacb032

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/captagent.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ static void print_all_devices()
139139
pcap_if_t *all_devs, *d = NULL;
140140
char err_buff[PCAP_ERRBUF_SIZE];
141141

142-
printf("List of available devices on your system:\n");
143-
if (pcap_findalldevs(&all_devs, err_buff) == -1) {
142+
if (pcap_findalldevs(&all_devs, err_buff) == PCAP_ERROR) {
144143
fprintf(stderr, "Error in pcap_findalldevs: %s\n", err_buff);
145-
usage(0);
146144
exit(-1);
147145
}
146+
147+
printf("List of available devices on your system:\n");
148148
for (d = all_devs; d; d = d->next) {
149149
if ((strncmp(d->name, "any", 3) != 0) && (strncmp(d->name, "lo", 2) != 0)) {
150150
printf("device %d = %s", ++i, d->name);
@@ -154,6 +154,7 @@ static void print_all_devices()
154154
printf("\t\t No description available for this device\n");
155155
}
156156
}
157+
pcap_freealldevs(all_devs);
157158
}
158159

159160

0 commit comments

Comments
 (0)