[Bug libdw/23301] free on unitialized value

mark at klomp dot org sourceware-bugzilla@sourceware.org
Mon Jun 18 11:32:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=23301

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2018-06-17
                 CC|                            |mark at klomp dot org
           Assignee|unassigned at sourceware dot org   |mark at klomp dot org
     Ever confirmed|0                           |1
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Created attachment 11076
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11076&action=edit
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

--- Comment #2 from Luiz Angelo Daros de Luca <luizluca at gmail dot com> ---
Mark,

It works. Gcc does not blame me anymore.

Thanks.

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
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>

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Elfutils-devel mailing list