fix bug in processEvent function

This commit is contained in:
zhouyi 2022-12-14 15:44:34 +08:00 committed by Ben Clayton
parent 3b01ef99ae
commit 574190fb63

View File

@ -395,13 +395,20 @@ class Impl : public dap::Session {
auto data = new uint8_t[typeinfo->size()];
typeinfo->construct(data);
if (!d->field("body", [&](dap::Deserializer* d) {
return typeinfo->deserialize(d, data);
})) {
handlers.error("Failed to deserialize event '%s' body", event.c_str());
typeinfo->destruct(data);
delete[] data;
return {};
// "body" is an optional field for some events, such as "Terminated Event".
bool body_ok = true;
d->field("body", [&](dap::Deserializer* d) {
if (!typeinfo->deserialize(d, data)) {
body_ok = false;
}
return true;
});
if (!body_ok) {
handlers.error("Failed to deserialize event '%s' body", event.c_str());
typeinfo->destruct(data);
delete[] data;
return {};
}
return [=] {