[PATCH] dix: fix NULL pointer dereferenced in memset

Tiago Vignatti tiago.vignatti at nokia.com
Sat Jun 12 07:39:08 PDT 2010


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.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
Honestly I didn't check if the code surrounding this hunk of code really needs
or not this memset. I created the patch focused only in the actual problem.

 dix/privates.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dix/privates.c b/dix/privates.c
index ec818d4..4451aae 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -271,8 +271,9 @@ _dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type)
 	keys[PRIVATE_XSELINUX].created++;
     if (keys[type].offset == 0)
 	addr = 0;
+    else
+	memset(addr, '\0', keys[type].offset);
     *privates = addr;
-    memset(addr, '\0', keys[type].offset);
 }
 
 /*
-- 
1.7.1.226.g770c5



More information about the xorg-devel mailing list