From: Mark Wielaard Date: Wed, 3 Jun 2015 15:42:38 +0000 (+0200) Subject: libdw: Initialize filelist early in read_srclines. X-Git-Tag: elfutils-0.162~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20956b84ef14a4ca110e1b23754b756c09bb2ee9;p=thirdparty%2Felfutils.git libdw: Initialize filelist early in read_srclines. We might jump to "out" early on error. Then filelist might not be set yet and we might try to free garbage. Set it to the null_file early. Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index aa4d09cae..e9b81f6d6 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2015-06-06 Mark Wielaard + + * dwarf_getsrclines.c (read_srclines): Initialize filelist early. + 2015-05-27 Mark Wielaard * encoded-value.h (read_encoded_value): Check data d_size contains diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c index d49aedcc6..ba9649a69 100644 --- a/libdw/dwarf_getsrclines.c +++ b/libdw/dwarf_getsrclines.c @@ -91,6 +91,18 @@ read_srclines (Dwarf *dbg, size_t nfilelist = 0; unsigned int ndirlist = 0; + struct filelist null_file = + { + .info = + { + .name = "???", + .mtime = 0, + .length = 0 + }, + .next = NULL + }; + struct filelist *filelist = &null_file; + /* If there are a large number of lines, files or dirs don't blow up the stack. Stack allocate some entries, only dynamically malloc when more than MAX. */ @@ -238,17 +250,6 @@ read_srclines (Dwarf *dbg, fl; }) /* Now read the files. */ - struct filelist null_file = - { - .info = - { - .name = "???", - .mtime = 0, - .length = 0 - }, - .next = NULL - }; - struct filelist *filelist = &null_file; nfilelist = 1; if (unlikely (linep >= lineendp))