summaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-23 12:02:00 +0100
committerDamien George <damien.p.george@gmail.com>2014-10-23 12:02:00 +0100
commit37378f8a9d2b358fdde0f3451d816b7f506846cc (patch)
tree3d009e47661b41c5406143d7b47a5c85ea082246 /py/gc.c
parentf5d69794a86f7647de3f3b3efd282ed288b1cba6 (diff)
py: Clean up edge cases of malloc/realloc/free.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index 68b70ba18..24d8e1ac2 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -546,6 +546,12 @@ void *gc_realloc(void *ptr_in, mp_uint_t n_bytes) {
return gc_alloc(n_bytes, false);
}
+ // check for pure free
+ if (n_bytes == 0) {
+ gc_free(ptr_in);
+ return NULL;
+ }
+
mp_uint_t ptr = (mp_uint_t)ptr_in;
// sanity check the ptr