[Lldb-commits] [lldb] [lldb] Don't crash on malformed filesets (PR #98388)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 10 14:12:31 PDT 2024
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/98388
The memory read can fail for a malformed fileset. Handle it gracefully instead of passing a nullptr to the std::string constructor.
rdar://131477833
>From 30f9ae1d2a086e7cf6ef713cc1e7ca91490169e5 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 10 Jul 2024 14:11:15 -0700
Subject: [PATCH] [lldb] Don't crash on malformed filesets
The memory read can fail for a malformed fileset. Handle it gracefully
instead of passing a nullptr to the std::string constructor.
rdar://131477833
---
.../Mach-O-Fileset/ObjectContainerMachOFileset.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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;
More information about the lldb-commits
mailing list