[lldb][lldb-vscode] Fix nullptr dereference when JSON is not an object

Reviewed By: wallace

Differential Revision: https://reviews.llvm.org/D156977
This commit is contained in:
David Spickett 2023-08-03 09:22:14 +00:00
parent 62ea799e6c
commit bdeb35bda4

View File

@ -523,12 +523,13 @@ PacketStatus VSCode::GetNextObject(llvm::json::Object &object) {
}
return PacketStatus::JSONMalformed;
}
object = *json_value->getAsObject();
if (!json_value->getAsObject()) {
llvm::json::Object *object_ptr = json_value->getAsObject();
if (!object_ptr) {
if (log)
*log << "error: json packet isn't a object" << std::endl;
return PacketStatus::JSONNotObject;
}
object = *object_ptr;
return PacketStatus::Success;
}