[PATCH] dix: fix NULL pointer dereferenced in memset

Vignatti Tiago (Nokia-D/Helsinki) tiago.vignatti at nokia.com
Sat Jun 12 08:53:14 PDT 2010


Hey Jamey,

On Sat, Jun 12, 2010 at 05:23:09PM +0200, ext Jamey Sharp wrote:
> 
> On Sat, Jun 12, 2010 at 7:39 AM, Tiago Vignatti
> <tiago.vignatti at nokia.com> wrote:
> > Apparently memset doesn't complain if the memory area is null (addr) and
> > something is being written there. Even though, this patch guarantees that
> > nothing is written at 0x0 memory address.
> 
> I'm confused by this comment. Did you get a segfault, or what? What do
> you mean by "memset doesn't complain", and why is the patch necessary?
> 
> I've just checked POSIX and C99, and neither one specifies anything
> about memset's behavior when length is 0 and address is null. Seems
> like no correct implementation could possibly dereference the null
> pointer though...
> 

No, I didn't get a segfault. So this patch is not exactly necessarily.

I'm playing a bit with a static analysis tool, which complained about this
NULL pointer dereference. So maybe this patch stills valid as a matter to fix
only a bad habit of programming, right?


             Tiago


More information about the xorg-devel mailing list