aboutsummaryrefslogtreecommitdiff
path: root/src/common_memory.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-09-06 16:50:13 +0100
committergingerBill <bill@gingerbill.org>2021-09-06 16:50:13 +0100
commitf5615b204c199c4afea2c1c77e4a2212511f401d (patch)
tree3e350f9afbcb036f782608ed8698cdfa93903cd8 /src/common_memory.cpp
parentbc15ce302c0e095fe8db245194e59adc0533eebe (diff)
Minor fix to `heap_allocator_proc` in common_memory.cpp
Diffstat (limited to 'src/common_memory.cpp')
-rw-r--r--src/common_memory.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/common_memory.cpp b/src/common_memory.cpp
index 8d1161f25..bd3d2d5de 100644
--- a/src/common_memory.cpp
+++ b/src/common_memory.cpp
@@ -350,11 +350,16 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
gb_zero_size(ptr, size);
} break;
- case gbAllocation_Free: {
- free(old_memory);
- } break;
+ case gbAllocation_Free:
+ if (!old_memory) {
+ free(old_memory);
+ }
+ break;
case gbAllocation_Resize:
+ if (!old_memory) {
+ break;
+ }
if (size == 0) {
free(old_memory);
break;
@@ -381,10 +386,15 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
break;
case gbAllocation_Free:
- free(old_memory);
+ if (!old_memory) {
+ free(old_memory);
+ }
break;
case gbAllocation_Resize:
+ if (!old_memory) {
+ break;
+ }
if (size == 0) {
free(old_memory);
break;