[Lldb-commits] [lldb] [lldb] Don't crash on malformed filesets (PR #98388)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 10 14:13:01 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Jonas Devlieghere (JDevlieghere)
<details>
<summary>Changes</summary>
The memory read can fail for a malformed fileset. Handle it gracefully instead of passing a nullptr to the std::string constructor.
rdar://131477833
---
Full diff: https://github.com/llvm/llvm-project/pull/98388.diff
1 Files Affected:
- (modified) lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp (+3-3)
``````````diff
diff --git a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp
index 2dc71d85777ca..76141f7976413 100644
--- a/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp
+++ b/lldb/source/Plugins/ObjectContainer/Mach-O-Fileset/ObjectContainerMachOFileset.cpp
@@ -159,9 +159,9 @@ ParseFileset(DataExtractor &data, mach_header header,
fileset_entry_command entry;
data.CopyData(load_cmd_offset, sizeof(fileset_entry_command), &entry);
lldb::offset_t entry_id_offset = load_cmd_offset + entry.entry_id.offset;
- const char *id = data.GetCStr(&entry_id_offset);
- entries.emplace_back(entry.vmaddr + slide, entry.fileoff,
- std::string(id));
+ if (const char *id = data.GetCStr(&entry_id_offset))
+ entries.emplace_back(entry.vmaddr + slide, entry.fileoff,
+ std::string(id));
}
offset = load_cmd_offset + lc.cmdsize;
``````````
</details>
https://github.com/llvm/llvm-project/pull/98388
More information about the lldb-commits
mailing list