diff options
| author | Mark Wielaard <[email protected]> | 2015-06-03 17:42:38 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2015-06-08 11:44:44 +0200 |
| commit | 20956b84ef14a4ca110e1b23754b756c09bb2ee9 (patch) | |
| tree | 45159cc5984b01d2077f68affe7c58fcdcdb095e /libdw/dwarf_getsrclines.c | |
| parent | c5022e5e3b74d579d44fcf599577e2a2a4c93f15 (diff) | |
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 <[email protected]>
Diffstat (limited to 'libdw/dwarf_getsrclines.c')
| -rw-r--r-- | libdw/dwarf_getsrclines.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c index d49aedcc..ba9649a6 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)) |
