ubsan: member access within null pointer of union
authorAlan Modra <amodra@gmail.com>
Tue, 12 Apr 2022 12:20:09 +0000 (21:50 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 13 Apr 2022 00:37:21 +0000 (10:07 +0930)
Add some nonsense to cover "undefined behaviour".

* ldlang.c (section_for_dot): Avoid UB.

ld/ldlang.c

index 1c8d229326cfa3b1647dbba4aea43f98204c6512..f10557af8428ccbca83a57de9ca315f8afff5660 100644 (file)
@@ -6726,7 +6726,7 @@ section_for_dot (void)
        if (stmt->header.type == lang_output_section_statement_enum)
          break;
 
-      os = &stmt->output_section_statement;
+      os = stmt ? &stmt->output_section_statement : NULL;
       while (os != NULL
             && !os->after_end
             && (os->bfd_section == NULL