summaryrefslogtreecommitdiffstatshomepage
path: root/py/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/py/gc.c b/py/gc.c
index d0ba26ddd3..86cea0827c 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -442,14 +442,17 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
if (n_bytes <= n_existing) {
return ptr;
} else {
- // TODO false is incorrect! Should get value from current block!
- void *ptr2 = gc_alloc(n_bytes,
+ bool has_finaliser;
+ if (ptr == NULL) {
+ has_finaliser = false;
+ } else {
#if MICROPY_ENABLE_FINALISER
- FTB_GET(BLOCK_FROM_PTR((machine_uint_t)ptr))
+ has_finaliser = FTB_GET(BLOCK_FROM_PTR((machine_uint_t)ptr));
#else
- false
+ has_finaliser = false;
#endif
- );
+ }
+ void *ptr2 = gc_alloc(n_bytes, has_finaliser);
if (ptr2 == NULL) {
return ptr2;
}