2011/12/10 Alan Coopersmith <[email protected]>: > If we didn't go into the if (!autoconfig) { } block, the filename, > dirname, and sysdirname pointers were never initialized, but we > freed them outside the block, leading to potential memory corruption. > > Move the frees inside the block where they're initialized to avoid this. > > To avoid similar problems, move the declarations of the variables that > are only used in this block inside the block. > > Regression introduced by commit 3d635fe84d6de53e2f74203b10e89f7851fe3fc1 > > Found by gcc warning: > xf86Config.c: In function 'xf86HandleConfigFile': > xf86Config.c:2303:11: warning: 'filename' may be used uninitialized in this > function > xf86Config.c:2303:22: warning: 'dirname' may be used uninitialized in this > function > xf86Config.c:2303:32: warning: 'sysdirname' may be used uninitialized in this > function > > Signed-off-by: Alan Coopersmith <[email protected]> Reviewed-by: Paulo Zanoni <[email protected]>
Another option would have been to set everything to NULL. The funniest thing here was trying to find out why I didn't have this warning on my machine. I put some stuff in CFLAGS, so I don't get "-O2" in my compilation, so gcc can't detect the uninitialized usage. Thanks, Paulo -- Paulo Zanoni _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
