[LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp (part 2)
authorSlava Gurevich <sgurevich@gmail.com>
Thu, 11 Aug 2022 07:11:35 +0000 (00:11 -0700)
committerSlava Gurevich <sgurevich@gmail.com>
Fri, 12 Aug 2022 04:08:18 +0000 (21:08 -0700)
Add the fixes suggested post-push in D131554

Differential Revision: https://reviews.llvm.org/D131743

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

index e4832da..dbf3aff 100644 (file)
@@ -4114,16 +4114,15 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
         switch (n_type) {
         case N_INDR: {
           const char *reexport_name_cstr = strtab_data.PeekCStr(nlist.n_value);
-          if (reexport_name_cstr && reexport_name_cstr[0]) {
+          if (reexport_name_cstr && reexport_name_cstr[0] && symbol_name) {
             type = eSymbolTypeReExported;
             ConstString reexport_name(reexport_name_cstr +
                                       ((reexport_name_cstr[0] == '_') ? 1 : 0));
             sym[sym_idx].SetReExportedSymbolName(reexport_name);
             set_value = false;
             reexport_shlib_needs_fixup[sym_idx] = reexport_name;
-            indirect_symbol_names.insert(ConstString(
-                symbol_name +
-                ((symbol_name && (symbol_name[0] == '_')) ? 1 : 0)));
+            indirect_symbol_names.insert(
+                ConstString(symbol_name + ((symbol_name[0] == '_') ? 1 : 0)));
           } else
             type = eSymbolTypeUndefined;
         } break;
@@ -6898,10 +6897,9 @@ ObjectFileMachO::GetCorefileAllImageInfos() {
         }
         uint32_t imgcount = m_data.GetU32(&offset);
         uint64_t entries_fileoff = m_data.GetU64(&offset);
-        /* leaving the following dead code as comments for spec documentation
-            offset += 4; // uint32_t entries_size;
-            offset += 4; // uint32_t unused;
-        */
+        // 'entries_size' is not used, nor is the 'unused' entry.
+        //  offset += 4; // uint32_t entries_size;
+        //  offset += 4; // uint32_t unused;
 
         offset = entries_fileoff;
         for (uint32_t i = 0; i < imgcount; i++) {