Wireshark mailing list archives

Re: [Wireshark-commits] rev 35975: /trunk/epan/dfilter/ /trunk/epan/dfilter/: dfilter-macro.c dfilter.c


From: Guy Harris <guy () alum mit edu>
Date: Thu, 17 Feb 2011 01:23:41 -0800


On Feb 17, 2011, at 12:58 AM, Guy Harris wrote:

It would be nice if the code analyzer bug in question didn't exist

And they appear to understand that it would be a bug:

        http://msdn.microsoft.com/en-us/library/2ayc37ac.aspx

"The following code generates this warning because a call to malloc might return null if there is insufficient memory 
available:

        #include <malloc.h>

        void f( )
        { 
          char *p = ( char * ) malloc( 10 );
          *p = '\0';
  
          // code ...
         free( p );
        }

To correct this warning, examine the pointer for null value as shown in the following code:

        #include <malloc.h>
        void f( )
        {
          char *p = ( char * )malloc ( 10 );
          if ( p ) 
          {
            *p = '\0';
            // code ...
    
            free( p );
          }
        }
"

(not "if ( p != NULL )", just "if ( p )").

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: