[Winpcap-users] pcap_freealldevs() causing program crash.

Gianluca Varenni gianluca.varenni at cacetech.com
Wed Nov 16 17:26:48 GMT 2005


Well, there's no relationship between pcap_open and pcap_findalldevs (apart from the fact that you may have used the adapter names returned by pcap_findalldevs to open an adapter with pcap_open).

pcap_freealldevs should always be called (once) after a successful call to pcap_findalldevs. 

Have a nice day
GV

  ----- Original Message ----- 
  From: Eric Hansen 
  To: winpcap-users at winpcap.org 
  Sent: Wednesday, November 16, 2005 9:01 AM
  Subject: Re: [Winpcap-users] pcap_freealldevs() causing program crash.


  Yup :)  I've debugged the pointer to, to make sure there wasn't something I wasn't catching otherwise.  I think I found my problem though.  What if I do not call pcap_open()?  For example, if I don't call that, should I still be calling freealldevs()?


  On 11/16/05, Gianluca Varenni <gianluca.varenni at cacetech.com > wrote:
    Hi.

    Did you also check that you aren't calling CDevice::Cleanup multiple times on the same "devs" pointer (thus trying to free the adapters list multiple times)?

    Have a nice day
    GV

      ----- Original Message ----- 
      From: Eric Hansen 
      To: WinPCap Mailing List 
      Sent: Sunday, November 13, 2005 4:04 PM
      Subject: [Winpcap-users] pcap_freealldevs() causing program crash.


      Does anyone know why, whenever I put in "pcap_freealldevs(devs);" into my cleanup code (that frees all the memory, etc...that my program uses), it always crashes?

      devs declaration:
      pcap_if_t *devs, *d; // Device list

      My cleanup code:
      void CDevice::Cleanup(){

          // Free the device list
          pcap_freealldevs(devs);
      }

      and how I'm using devs:
      void CDevice::Devices(){
          if(pcap_findalldevs(&devs, error) == -1){
              AfxMessageBox(error);
          } else{
              for(iCount = 0, d = devs; d != NULL; d = d->next, iCount++){
                  if(d->description){
                      cDescription[iCount] = d->description;
                  }

                  cDevice[iCount] = d->name;
                  }
              }
      }

      I've been racking my brain for over an hour trying to figure out what I'm doing.

      (Note: I call Cleanup() in the WM_DESTROY Windows message)



--------------------------------------------------------------------------


      _______________________________________________
      Winpcap-users mailing list
      Winpcap-users at winpcap.org
      https://www.winpcap.org/mailman/listinfo/winpcap-users



    _______________________________________________
    Winpcap-users mailing list
    Winpcap-users at winpcap.org
    https://www.winpcap.org/mailman/listinfo/winpcap-users






  -- 
  http://tenshi.honeyblade.net (my poetry)

  "You wanted this ending to happen...ROMANTISUTO!" 


------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20051116/0f1455e0/attachment.htm


More information about the Winpcap-users mailing list