summaryrefslogtreecommitdiffstatshomepage
path: root/py/malloc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-02-01 21:32:05 +0000
committerDamien George <damien.p.george@gmail.com>2016-04-18 15:09:34 +0100
commit1c0343f9d991c241d335712593f3a63858dc91b6 (patch)
tree2f2757a37edaffcfbf448a6acb0e1bbe524f525c /py/malloc.c
parent2d9531a777e01c982ce8f2e5867b05bbac74373c (diff)
downloadmicropython-1c0343f9d991c241d335712593f3a63858dc91b6.tar.gz
micropython-1c0343f9d991c241d335712593f3a63858dc91b6.zip
py/gc: Zero out all newly allocated memory to prevent stale pointers.
Diffstat (limited to 'py/malloc.c')
-rw-r--r--py/malloc.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/py/malloc.c b/py/malloc.c
index b0493d9341..c837ed5735 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -114,10 +114,7 @@ void *m_malloc_with_finaliser(size_t num_bytes) {
void *m_malloc0(size_t num_bytes) {
void *ptr = m_malloc(num_bytes);
- if (ptr == NULL && num_bytes != 0) {
- return m_malloc_fail(num_bytes);
- }
- memset(ptr, 0, num_bytes);
+ // memory is already cleared by gc_alloc
return ptr;
}