py, gc: Fix old gc_realloc for case when NULL is passed in as ptr.
This commit is contained in:
parent
5be40afb4c
commit
410f30772f
13
py/gc.c
13
py/gc.c
|
@ -435,14 +435,17 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
|
||||||
if (n_bytes <= n_existing) {
|
if (n_bytes <= n_existing) {
|
||||||
return ptr;
|
return ptr;
|
||||||
} else {
|
} else {
|
||||||
// TODO false is incorrect! Should get value from current block!
|
bool has_finaliser;
|
||||||
void *ptr2 = gc_alloc(n_bytes,
|
if (ptr == NULL) {
|
||||||
|
has_finaliser = false;
|
||||||
|
} else {
|
||||||
#if MICROPY_ENABLE_FINALISER
|
#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
|
#else
|
||||||
false
|
has_finaliser = false;
|
||||||
#endif
|
#endif
|
||||||
);
|
}
|
||||||
|
void *ptr2 = gc_alloc(n_bytes, has_finaliser);
|
||||||
if (ptr2 == NULL) {
|
if (ptr2 == NULL) {
|
||||||
return ptr2;
|
return ptr2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue