diff --git a/tcpdump.c b/tcpdump.c index 2e3eb26c..6e6dc29c 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1237,8 +1237,11 @@ _U_ for (i = 0, dev = devlist; i < devnum-1 && dev != NULL; i++, dev = dev->next) ; - if (dev == NULL) - error("Invalid adapter index"); + if (dev == NULL) { + pcap_freealldevs(devlist); + error("Invalid adapter index %ld: only %ld interfaces found", + devnum, i); + } device = strdup(dev->name); pcap_freealldevs(devlist); return (device);