Ugh of course I screwed up the malloc() test. Fixed a crash on GTK+ since I guess OS X malloc() autofills to 0?

This commit is contained in:
Pietro Gagliardi 2017-02-20 15:14:53 -05:00
parent 6ae6e91238
commit ea473a3411
3 changed files with 3 additions and 2 deletions

View File

@ -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]];

View File

@ -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)

View File

@ -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;