aboutsummaryrefslogtreecommitdiff
path: root/src/range_set.cpp
diff options
context:
space:
mode:
authorTyler Philbrick <t5j6p9@gmail.com>2019-04-23 00:47:55 -0700
committerhryx <codroid@gmail.com>2019-05-12 01:54:30 -0700
commit16aee1f58a80295f7599a8290d764a5c7040c373 (patch)
tree5aad83f912fff8f1b32ca4c03e313ebbdaa4b9be /src/range_set.cpp
parent4e28c2571d375e8e04df19074694f3fef252092c (diff)
downloadzig-16aee1f58a80295f7599a8290d764a5c7040c373.tar.gz
zig-16aee1f58a80295f7599a8290d764a5c7040c373.zip
Fix memory leak in parser tests
The `arena` instance being used bythe parse tree was valid and pointed to valid memory, but existed as a local variable inside the stack frame of the `parse` function (the `const arena`), which was never stored anywhere before leaving the scope. This meant that code above the `parse` function saw a valid instance of an `ArenaAllocator` that pointed to the same backing memory, but didn't posess any of the local state built up after the call to `parseRoot`, basically the caller saw an empty arena. This meant that when `deinit` was called, it saw an Arena with 0 allocations in it's `buffer_list` and wasn't able to destroy any of the memory. This caused it to leak and caused FailingAllocator to balk. The fix is to make sure the parse tree is using the same instance of ArenaAllocator as is reported up the call stack, the one inside the `Tree{}` object. I'm not sure why that field is marked with a comment to remove it, as it's used by the `std.ast.Tree.deinit()` function, but this change seems to solve the problem.
Diffstat (limited to 'src/range_set.cpp')
0 files changed, 0 insertions, 0 deletions