Fix bad memory access in ReplaceAll
This commit is contained in:
@@ -1152,6 +1152,7 @@ API void InitBuffer(Allocator allocator, Buffer *buffer, BufferID id = {}, Strin
|
||||
if (!buffer->no_line_starts) {
|
||||
Add(&buffer->line_starts, (Int)0);
|
||||
}
|
||||
if (DebugTraceBufferInits) printf("InitBuffer %.*s %p\n", (int)name.len, name.data, buffer->data);
|
||||
}
|
||||
|
||||
API void DeinitBuffer(Buffer *buffer) {
|
||||
@@ -1161,6 +1162,7 @@ API void DeinitBuffer(Buffer *buffer) {
|
||||
Dealloc(&buffer->line_starts);
|
||||
DeallocHistoryArray(&buffer->undo_stack);
|
||||
DeallocHistoryArray(&buffer->redo_stack);
|
||||
if (DebugTraceBufferInits) printf("DeinitBuffer %.*s %p\n", (int)buffer->name.len, buffer->name.data, buffer->data);
|
||||
}
|
||||
|
||||
// Indexing starts from 0 not 1 because this routine creates also the zero buffer
|
||||
|
||||
@@ -9,6 +9,7 @@ bool SearchCaseSensitive = false;
|
||||
bool SearchWordBoundary = false;
|
||||
bool BreakOnError = false;
|
||||
Int ErrorCount;
|
||||
bool DebugTraceBufferInits = false;
|
||||
|
||||
Allocator SysAllocator = {SystemAllocatorProc};
|
||||
float DPIScale = 1.0f;
|
||||
|
||||
@@ -140,7 +140,7 @@ void CO_ReplaceAll(mco_coro *co) {
|
||||
|
||||
field_seek = BaseFindNext(main.buffer, u"for::", MakeCaret(0), SeekFlag_None);
|
||||
Range range = {field_seek.range.max, main.buffer->len};
|
||||
needle = GetString(main.buffer, range);
|
||||
needle = Copy16(ctx->arena, GetString(main.buffer, range));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
- [x] ReplaceAll - heap-use-after-free address, how to debug? I think would be nice to iterate all buffer ids and their addresses along with the state
|
||||
|
||||
- [x] BRO, the caret teleports on linux when I press the arrow for too long
|
||||
- [ ] Report SDL newest vs SDL previous version on wayland
|
||||
|
||||
@@ -900,8 +902,8 @@ int main(int argc, char **argv, char **envp)
|
||||
char **argv = __argv;
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
#endif
|
||||
InitScratch();
|
||||
InitOS(ReportErrorf);
|
||||
InitScratch();
|
||||
|
||||
ProjectFolder = GetWorkingDir(Perm);
|
||||
HomeFolder = SDL_GetUserFolder(SDL_FOLDER_HOME);
|
||||
|
||||
Reference in New Issue
Block a user