Fixed realloc() bug