asan: applying zero offset to NULL pointer
authorAlan Modra <amodra@gmail.com>
Thu, 9 Jun 2022 13:49:03 +0000 (23:19 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 14 Jun 2022 00:26:45 +0000 (09:56 +0930)
* dwarf.c (fetch_indexed_string): Move initialisation of "curr"
and "end" after checking for missing section.

binutils/dwarf.c

index caa3ce48d00df7b5ea44412f223d7acfdcca9fe2..c16f5a891b7b9c4402b2d0843d52eaf3235da09a 100644 (file)
@@ -700,8 +700,7 @@ fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set,
   dwarf_vma index_offset;
   dwarf_vma str_offset;
   const char * ret;
-  unsigned char *curr = index_section->start;
-  unsigned char *end = curr + index_section->size;
+  unsigned char *curr, *end;
   dwarf_vma length;
 
   if (index_section->start == NULL)
@@ -712,6 +711,8 @@ fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set,
     return (dwo ? _("<no .debug_str.dwo section>")
                : _("<no .debug_str section>"));
 
+  curr = index_section->start;
+  end = curr + index_section->size;
   /* FIXME: We should cache the length...  */
   SAFE_BYTE_GET_AND_INC (length, curr, 4, end);
   if (length == 0xffffffff)