summaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-10-30 14:57:23 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-11-02 11:25:10 -0400
commitd09b784e395554cb67ec91e70544a052fe60a276 (patch)
tree7ac772d169160cd0d274203e0fd2b09e74023427 /src/alloc.c
parent1466fb2400af367db9d0cb1041020278a871a4f3 (diff)
downloadbfs-d09b784e395554cb67ec91e70544a052fe60a276.tar.xz
sanity: Don't mark memory uninit in sanitize_{alloc,free}()
We might want to change the size of an allocated region without changing which bytes are initialized.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 79e4ce7..ef9f6ab 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -228,6 +228,7 @@ void arena_free(struct arena *arena, void *ptr) {
union chunk *chunk = ptr;
chunk_set_next(arena, chunk, arena->chunks);
arena->chunks = chunk;
+ sanitize_uninit(chunk, arena->size);
sanitize_free(chunk, arena->size);
}
@@ -334,15 +335,16 @@ void *varena_realloc(struct varena *varena, void *ptr, size_t old_count, size_t
}
size_t old_size = old_arena->size;
- sanitize_alloc((char *)ptr + old_exact_size, old_size - old_exact_size);
+ sanitize_alloc(ptr, old_size);
size_t new_size = new_arena->size;
size_t min_size = new_size < old_size ? new_size : old_size;
memcpy(ret, ptr, min_size);
arena_free(old_arena, ptr);
- sanitize_free((char *)ret + new_exact_size, new_size - new_exact_size);
+ sanitize_free(ret, new_size);
+ sanitize_alloc(ret, new_exact_size);
return ret;
}