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()]; auto data = new uint8_t[typeinfo->size()];
typeinfo->construct(data); typeinfo->construct(data);
if (!d->field("body", [&](dap::Deserializer* d) { // "body" is an optional field for some events, such as "Terminated Event".
return typeinfo->deserialize(d, data); bool body_ok = true;
})) { d->field("body", [&](dap::Deserializer* d) {
handlers.error("Failed to deserialize event '%s' body", event.c_str()); if (!typeinfo->deserialize(d, data)) {
typeinfo->destruct(data); body_ok = false;
delete[] data; }
return {}; return true;
});
if (!body_ok) {
handlers.error("Failed to deserialize event '%s' body", event.c_str());
typeinfo->destruct(data);
delete[] data;
return {};
} }
return [=] { return [=] {