From ea473a341187c71fbe2685f7e6009be041f7c5f6 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 20 Feb 2017 15:14:53 -0500 Subject: [PATCH] Ugh of course I screwed up the malloc() test. Fixed a crash on GTK+ since I guess OS X malloc() autofills to 0? --- darwin/alloc.m | 2 +- unix/alloc.c | 2 +- windows/alloc.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/darwin/alloc.m b/darwin/alloc.m index e271b90e..0bbb8996 100644 --- a/darwin/alloc.m +++ b/darwin/alloc.m @@ -71,7 +71,7 @@ void *uiRealloc(void *p, size_t new, const char *type) abort(); } s = SIZE(out); - if (new <= *s) + if (new > *s) memset(((uint8_t *) DATA(out)) + *s, 0, new - *s); *s = new; [allocations removeObject:[NSValue valueWithPointer:p]]; diff --git a/unix/alloc.c b/unix/alloc.c index 2561efa6..0291bd49 100644 --- a/unix/alloc.c +++ b/unix/alloc.c @@ -64,7 +64,7 @@ void *uiRealloc(void *p, size_t new, const char *type) p = BASE(p); out = g_realloc(p, EXTRA + new); s = SIZE(out); - if (new <= *s) + if (new > *s) memset(((uint8_t *) DATA(out)) + *s, 0, new - *s); *s = new; if (g_ptr_array_remove(allocations, p) == FALSE) diff --git a/windows/alloc.cpp b/windows/alloc.cpp index eeee3ad4..23201f75 100644 --- a/windows/alloc.cpp +++ b/windows/alloc.cpp @@ -45,6 +45,7 @@ void *uiRealloc(void *_p, size_t size, const char *type) if (p == NULL) return uiAlloc(size, type); arr = heap[p]; + // TODO does this fill in? arr->resize(size, 0); heap.erase(p); heap[rawBytes(arr)] = arr;