[PATCH 4/4] XkbSendNames: fix use of uninitialised bytes valgrind error.

Ander Conselvan de Oliveira ander.conselvan-de-oliveira at nokia.com
Tue Feb 8 01:10:11 PST 2011


==537== Syscall param writev(vector[...]) points to uninitialised byte(s)
==537==    at 0x4AB7154: writev (writev.c:51)
==537==    by 0x8935B: _XSERVTransWritev (Xtrans.c:912)
==537==    by 0x6C55F: FlushClient (io.c:924)
==537==    by 0x6CCF3: WriteToClient (io.c:846)
==537==    by 0xD51D3: XkbSendNames (xkb.c:3765)
==537==    by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825)
==537==    by 0x27B7B: Dispatch (dispatch.c:432)
==537==    by 0x205B7: main (main.c:291)
==537==  Address 0x55899f2 is 154 bytes inside a block of size 1,896 alloc'd
==537==    at 0x4834C48: malloc (vg_replace_malloc.c:236)
==537==    by 0xD47AF: XkbSendNames (xkb.c:3642)
==537==    by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825)
==537==    by 0x27B7B: Dispatch (dispatch.c:432)
==537==    by 0x205B7: main (main.c:291)
==537==  Uninitialised value was created by a heap allocation
==537==    at 0x4834C48: malloc (vg_replace_malloc.c:236)
==537==    by 0xD47AF: XkbSendNames (xkb.c:3642)
==537==    by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825)
==537==    by 0x27B7B: Dispatch (dispatch.c:432)
==537==    by 0x205B7: main (main.c:291)
---
 xkb/xkb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xkb/xkb.c b/xkb/xkb.c
index ac1fe59..a57139f 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -3644,7 +3644,7 @@ register int            n;
 	swapl(&rep->indicators,n);
     }
 
-    start = desc = malloc(length);
+    start = desc = calloc(1, length);
     if ( !start )
 	return BadAlloc;
     if (xkb->names) {
-- 
1.7.0.4



More information about the xorg-devel mailing list