fix for setting object locations to avoid use-after-free situation

This commit is contained in:
Vern Paxson 2024-09-11 16:31:23 +02:00 committed by Christian Kreibich
parent a68ffc5316
commit 07d211419a

View file

@ -130,11 +130,14 @@ bool Obj::SetLocationInfo(const detail::Location* start, const detail::Location*
// We already have a better location, so don't use this one.
return true;
delete location;
location =
auto new_location =
new detail::Location(start->filename, start->first_line, end->last_line, start->first_column, end->last_column);
// Don't delete this until we've constructed the new location, in case
// "start" or "end" are our own location.
delete location;
location = new_location;
return true;
}