gc: Don't segfault if gc_realloc() fails.

This commit is contained in:
Paul Sokolovsky 2014-02-11 15:28:37 +02:00
parent a075741c90
commit c0a8374103
1 changed files with 3 additions and 0 deletions

View File

@ -332,6 +332,9 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
} else {
// TODO check if we can grow inplace
void *ptr2 = gc_alloc(n_bytes);
if (ptr2 == NULL) {
return ptr2;
}
memcpy(ptr2, ptr, n_existing);
gc_free(ptr);
return ptr2;