summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-25 11:44:53 +0000
committerDamien George <damien.p.george@gmail.com>2014-04-25 11:44:53 +0000
commit410f30772fa3e121d1c6f8c9e2418fad7579e6f4 (patch)
tree83188508f0688587301d37aa82e89655809e726a /py
parent5be40afb4c50e6a71a0b6c7d0e7b63c4abe5b7b5 (diff)
downloadmicropython-410f30772fa3e121d1c6f8c9e2418fad7579e6f4.tar.gz
micropython-410f30772fa3e121d1c6f8c9e2418fad7579e6f4.zip
py, gc: Fix old gc_realloc for case when NULL is passed in as ptr.
Diffstat (limited to 'py')
-rw-r--r--py/gc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/py/gc.c b/py/gc.c
index 9a5f9d89bf..68ddfd4cad 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -435,14 +435,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;
}