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;