Fix memory leak when printing any error's source code. (#12831)

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
dave caruso
2024-07-26 14:14:16 -07:00
committed by GitHub
parent 7aa05ec542
commit bf8b6922bb
6 changed files with 72 additions and 20 deletions

View File

@@ -3246,6 +3246,9 @@ pub const VirtualMachine = struct {
var exception = exception_holder.zigException();
defer exception_holder.deinit(this);
// The ZigException structure stores substrings of the source code, in
// which we need the lifetime of this data to outlive the inner call to
// remapZigException, but still get freed.
var source_code_slice: ?ZigString.Slice = null;
defer if (source_code_slice) |slice| slice.deinit();