Created attachment 11075 [details] patch: dwarf_getsrclines.c: Fix unitialized usage of filelist I'm getting this error with 0.172: dwarf_getsrclines.c: In function 'read_srclines': dwarf_getsrclines.c:1074:7: error: 'filelist' may be used uninitialized in this function [-Werror=maybe-uninitialized] free (filelist); ^~~~~~~~~~~~~~~ It seems that gcc is right here as there is "ifs" that go to "out" (where filelist is freed) before freelist is initialized. I fixed by just moving filelist initialization to before the first usage of "goto out;". Maybe there is a more elegant approach.
Created attachment 11076 [details] libdw: Initialize filelist earlier in dwarf_getsrclines.c read_srclines. Hi, gcc is wrong, filelist will not be used/freed if nfilelist == 0, and filelist will be initialized if nfilelist != 0. But this might be hard to see for the compiler. BTW which gcc version is this, any special CFLAGS used? Instead of moving the whole block of code around I think just explicitly setting filelist to NULL when we initialize nfilelist = 0 should do the trick. Could you test the slightly changed patch attached? Also would it me OK to add a Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com> line as described in https://sourceware.org/git/?p=elfutils.git;a=blob_plain;f=CONTRIBUTING;hb=HEAD Thanks, Mark
Mark, It works. Gcc does not blame me anymore. Thanks.
commit 9e16a100bf8e0d43415253fe8cfd3ba1d8e637d1 Author: Luiz Angelo Daros de Luca <luizluca@gmail.com> Date: Sun Jun 17 11:34:08 2018 +0200 libdw: Initialize filelist earlier in dwarf_getsrclines.c read_srclines. I'm getting this error with 0.172: dwarf_getsrclines.c: In function 'read_srclines': dwarf_getsrclines.c:1074:7: error: 'filelist' may be used uninitialized in t free (filelist); ^~~~~~~~~~~~~~~ It seems that gcc is right here as there is "ifs" that go to "out" (where filelist is freed) before freelist is initialized. Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>