[llvm-branch-commits] [lldb] r270100 - Fixed a crasher when dealing with table entries that have blank names.

Francis Ricci via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 19 13:05:32 PDT 2016


Author: fjricci
Date: Thu May 19 15:05:32 2016
New Revision: 270100

URL: http://llvm.org/viewvc/llvm-project?rev=270100&view=rev
Log:
Fixed a crasher when dealing with table entries that have blank names.

This can happen with -gmodules tables when an anonymous struct is referred to.

Modified:
    lldb/branches/release_38/include/lldb/Core/MappedHash.h
    lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
    lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/branches/release_38/include/lldb/Core/MappedHash.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/include/lldb/Core/MappedHash.h?rev=270100&r1=270099&r2=270100&view=diff
==============================================================================
--- lldb/branches/release_38/include/lldb/Core/MappedHash.h (original)
+++ lldb/branches/release_38/include/lldb/Core/MappedHash.h Thu May 19 15:05:32 2016
@@ -47,6 +47,9 @@ public:
     static uint32_t
     HashString (uint32_t hash_function, const char *s)
     {
+        if (!s)
+            return 0;
+        
         switch (hash_function)
         {
             case MappedHash::eHashFunctionDJB:
@@ -434,6 +437,9 @@ public:
         bool
         Find (const char *name, Pair &pair) const
         {
+            if (!name || !name[0])
+                return false;
+
             if (IsValid ())
             {
                 const uint32_t bucket_count = m_header.bucket_count;

Modified: lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp?rev=270100&r1=270099&r2=270100&view=diff
==============================================================================
--- lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (original)
+++ lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp Thu May 19 15:05:32 2016
@@ -671,6 +671,9 @@ DWARFMappedHash::MemoryTable::AppendAllD
 size_t
 DWARFMappedHash::MemoryTable::FindByName (const char *name, DIEArray &die_offsets)
 {
+    if (!name || !name[0])
+        return 0;
+    
     DIEInfoArray die_info_array;
     if (FindByName(name, die_info_array))
         DWARFMappedHash::ExtractDIEArray (die_info_array, die_offsets);
@@ -736,6 +739,9 @@ DWARFMappedHash::MemoryTable::FindComple
 size_t 
 DWARFMappedHash::MemoryTable::FindByName (const char *name, DIEInfoArray &die_info_array)
 {
+    if (!name || !name[0])
+        return 0;
+
     Pair kv_pair;
     size_t old_size = die_info_array.size();
     if (Find (name, kv_pair))

Modified: lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=270100&r1=270099&r2=270100&view=diff
==============================================================================
--- lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/branches/release_38/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu May 19 15:05:32 2016
@@ -3082,6 +3082,9 @@ SymbolFileDWARF::FindTypes (const std::v
 
     ConstString name = context.back().name;
 
+    if (!name)
+        return 0;
+
     if (m_using_apple_tables)
     {
         if (m_apple_types_ap.get())




More information about the llvm-branch-commits mailing list