]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Don't close a pcap_t until we're done with its error buffer.
authorGuy Harris <[email protected]>
Mon, 6 Feb 2017 23:28:50 +0000 (15:28 -0800)
committerDenis Ovsienko <[email protected]>
Fri, 21 Jul 2017 13:30:28 +0000 (14:30 +0100)
tcpdump.c

index 3ebb437bb48f3bc8faf353c18a8992cc463dc484..8b2903f6f243b9c0c06bf8c7fc4d791de7bca1ba 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1046,9 +1046,9 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
                        /*
                         * Return an error for our caller to handle.
                         */
-                       pcap_close(pc);
                        snprintf(ebuf, PCAP_ERRBUF_SIZE, "%s: %s\n(%s)",
                            device, pcap_statustostr(status), cp);
+                       pcap_close(pc);
                        return (NULL);
                } else if (status == PCAP_ERROR_PERM_DENIED && *cp != '\0')
                        error("%s: %s\n(%s)", device,