mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
fix for setting object locations to avoid use-after-free situation
This commit is contained in:
parent
a68ffc5316
commit
07d211419a
1 changed files with 6 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue