From bb79f03833440854b7c11b5d93e835fe8c4194a7 Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi@cloudius-systems.com>
Date: Sun, 20 Jan 2013 13:50:24 +0200
Subject: [PATCH] elf: fix segfault on unmatched symbol

lookup_symbol() checks if the symbol is undefined, before checking if we
actually looked it up.  Check for a missing symbol first.
---
 elf.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elf.cc b/elf.cc
index a1c24517d..8ac735922 100644
--- a/elf.cc
+++ b/elf.cc
@@ -487,7 +487,7 @@ namespace elf {
         } else {
             sym = lookup_symbol_old(name);
         }
-        if (sym->st_shndx == SHN_UNDEF) {
+        if (sym && sym->st_shndx == SHN_UNDEF) {
             sym = nullptr;
         }
         return sym;
-- 
GitLab