[PATCH] gold: fix crash for empty file

Martin Liška mliska@suse.cz
Fri Nov 19 14:01:52 GMT 2021


Hi.

The patch fixes a crash I noticed and explained in the linked PR.

Patch survives regression tests.

Ready to be installed?
Thanks,
Martin

gold/ChangeLog:

	PR 28585
	* symtab.cc (Symbol_table::lookup): Return NULL for NULL
	argument.
---
  gold/symtab.cc | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/gold/symtab.cc b/gold/symtab.cc
index 5a21ddc8cc2..ed6b5434592 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -701,6 +701,8 @@ Symbol_table::resolve_forwards(const Symbol* from) const
  Symbol*
  Symbol_table::lookup(const char* name, const char* version) const
  {
+  if (name == NULL)
+    return NULL;
    Stringpool::Key name_key;
    name = this->namepool_.find(name, &name_key);
    if (name == NULL)
-- 
2.33.1



More information about the Binutils mailing list