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 Tim Wojtulewicz
parent 10d5ca5948
commit bcfd47c28d

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;
}