[Winpcap-users] Problem Freeing Array Returned by pcap_list_datalinks

Yaser Zhian yzt at gmx.net
Sun Sep 10 06:29:15 GMT 2006


Hi,

I am trying to use pcap_list_datalinks() to get a list of all the
datalink types supported by my network interface. The result of the
function is OK, and the reported types are as expected, but when I
try to free() the allocated buffer, I get an assertion failure in
Visual C++.

I'm using WinPCAP version 3.1 (this is return value of
pcap_lib_version() : 'WinPcap version 3.1 (packet.dll version 3, 1,
0, 27), based on libpcap version 0.9[.x]') and I'm on Windows XP
(sp2) and Visual C++ 8.0 (VS 2005).

I'm compiling my program in debug mode using the multi-threaded
version of the CRT (non-DLL, but I checked the DLL version and it
has the exact same problem.)

The problem is reported in CRT's "dbgheap.c" (called from the free()
function in debug mode to track memory leaks.)

The following code also generates the same failure:

 int * dltlist = 0;
 int r = pcap_list_datalinks (m_capturehnd, &dltlist);
 free (dltlist);

The problem occurs in the free() call. Am I doing something wrong?
Or is this just a false alarm? If it is, how can I work around it (I
need the debug mode.)

Thanks for your attention,
yzt

-- 
"Programming is an art that fights back!"


More information about the Winpcap-users mailing list