Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 35975: /trunk/epan/dfilter/ /trunk/e

From: Guy Harris <guy@xxxxxxxxxxxx>
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 )").