Fix memory corruption

This commit is contained in:
Krzosa Karol
2024-07-28 20:49:40 +02:00
parent 77a6cc5e53
commit 12b459507a
5 changed files with 19 additions and 15 deletions

View File

@@ -1034,8 +1034,11 @@ inline TempArena GetScratch(Arena *c1 = NULL, Arena *c2 = NULL) {
struct Scratch {
TempArena checkpoint;
Scratch() { this->checkpoint = GetScratch(); }
Scratch(Arena *conflict) { this->checkpoint = GetScratch(conflict); }
Scratch(Arena *c1, Arena *c2) { this->checkpoint = GetScratch(c1, c2); }
Scratch(Allocator conflict) { this->checkpoint = GetScratch((Arena *)conflict.object); }
Scratch(Allocator c1, Allocator c2) { this->checkpoint = GetScratch((Arena *)c1.object, (Arena *)c2.object); }
~Scratch() { EndTemp(checkpoint); }
operator Arena *() { return checkpoint.arena; }
operator Allocator() { return *checkpoint.arena; }

View File

@@ -270,7 +270,7 @@ String GetExePath(Allocator allocator) {
}
String GetExeDir(Allocator allocator) {
Scratch scratch;
Scratch scratch((Arena *)allocator.object);
String path = GetExePath(scratch);
path = ChopLastSlash(path);
path = Copy(allocator, path);