Skip to content

Commit 8692a72

Browse files
committed
fix realloc
1 parent 67ee6e9 commit 8692a72

File tree

1 file changed

+3
-1
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+3
-1
lines changed

graalpython/com.oracle.graal.python.cext/src/obmalloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void* PyMem_RawRealloc(void *ptr, size_t new_size) {
193193
mem_head_t* old;
194194

195195
if (ptr != NULL) {
196-
ptr = AS_MEM_HEAD(ptr);
196+
old = AS_MEM_HEAD(ptr);
197197

198198
// account for the difference in size
199199
if (old->size >= new_size) {
@@ -203,6 +203,8 @@ void* PyMem_RawRealloc(void *ptr, size_t new_size) {
203203
return NULL;
204204
}
205205
}
206+
} else {
207+
old = NULL;
206208
}
207209

208210
mem_head_t* ptr_with_head = (mem_head_t*) realloc(old, new_size + sizeof(mem_head_t));

0 commit comments

Comments
 (0)