]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Initialize filelist early in read_srclines.
authorMark Wielaard <mjw@redhat.com>
Wed, 3 Jun 2015 15:42:38 +0000 (17:42 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 8 Jun 2015 09:44:44 +0000 (11:44 +0200)
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 <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_getsrclines.c

index aa4d09cae53d087785f32118410ba4c0c2e9930e..e9b81f6d683056aa683125b46f8045905c8c6d05 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-06  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_getsrclines.c (read_srclines): Initialize filelist early.
+
 2015-05-27  Mark Wielaard  <mjw@redhat.com>
 
        * encoded-value.h (read_encoded_value): Check data d_size contains
index d49aedcc6d136f0f44f4a141b5dd9f8d88f88f7f..ba9649a697c092d66afd10c170a5c43359336ecc 100644 (file)
@@ -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))