diff options
author | Guy Harris <guy@alum.mit.edu> | 2008-07-04 03:33:00 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2008-07-04 03:33:00 +0000 |
commit | e82d99d2b4b86a22f37dd19481fdcbe8ca7635a8 (patch) | |
tree | c9fa56081cba2db8532d95df30deaee552e03d47 /capture-pcap-util.c | |
parent | d1275537c02918305015a9128a3f4efcb19408ab (diff) |
If we have pcap_free_datalinks(), use it. If not, then, on Windows,
just leak the list returned by pcap_list_datalinks(), as there's no
guarantee that if you have a library built with one version of the
MSVC++ run-time library, and it returns a pointer to allocated data, you
can free that data from a program linked with another version of the
MSVC++ run-time library. (This is not an issue on UN*X.)
This should fix bug 2677.
svn path=/trunk/; revision=25668
Diffstat (limited to 'capture-pcap-util.c')
-rw-r--r-- | capture-pcap-util.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/capture-pcap-util.c b/capture-pcap-util.c index 129712d426..0d7024af5f 100644 --- a/capture-pcap-util.c +++ b/capture-pcap-util.c @@ -412,11 +412,34 @@ get_pcap_linktype_list(const char *devname, char **err_str) linktype_list = g_list_append(linktype_list, data_link_info); } - free(linktypes); +#ifdef HAVE_PCAP_FREE_DATALINKS + pcap_free_datalinks(linktypes); #else + /* + * In Windows, there's no guarantee that if you have a library + * built with one version of the MSVC++ run-time library, and + * it returns a pointer to allocated data, you can free that + * data from a program linked with another version of the + * MSVC++ run-time library. + * + * This is not an issue on UN*X. + * + * See the mail threads starting at + * + * http://www.winpcap.org/pipermail/winpcap-users/2006-September/001421.html + * + * and + * + * http://www.winpcap.org/pipermail/winpcap-users/2008-May/002498.html + */ +#ifndef _WIN32 + free(linktypes); +#endif /* _WIN32 */ +#endif /* HAVE_PCAP_FREE_DATALINKS */ +#else /* HAVE_PCAP_LIST_DATALINKS */ data_link_info = create_data_link_info(deflt); linktype_list = g_list_append(linktype_list, data_link_info); -#endif +#endif /* HAVE_PCAP_LIST_DATALINKS */ pcap_close(pch); return linktype_list; |