Skip to content

Commit 28aa746

Browse files
committed
[lldb-dap] Fix segfault in JSONUtils.cpp when GetUUIDString() returns nullptr
When creating a stack frame in JSONUtils.cpp CreateStackFrame() the code constructs a std::string from module.GetUUIDString(), which can return nullptr in some cases (as documented in the implementation of SBModule::GetUUIDString()). This causes a segmentation fault when passed to the std::string constructor. This fix adds a null check before constructing the UUID string, falling back to an empty string if nullptr is returned. The existing empty check ensures the moduleId field is omitted from the JSON when no UUID exists.
1 parent 58fa7e4 commit 28aa746

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ llvm::json::Value CreateStackFrame(DAP &dap, lldb::SBFrame &frame,
554554

555555
lldb::SBModule module = frame.GetModule();
556556
if (module.IsValid()) {
557-
std::string uuid = module.GetUUIDString();
557+
const char *uuid_cstr = module.GetUUIDString();
558+
std::string uuid = uuid_cstr ? uuid_cstr : "";
558559
if (!uuid.empty())
559560
object.try_emplace("moduleId", uuid);
560561
}

0 commit comments

Comments
 (0)