From b4078cbbf3354229fc81ecfd26295237d808caa9 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 14 Aug 2017 12:14:05 +1000 Subject: Revert "py/gc: Zero out all newly allocated memory to prevent stale pointers." This reverts commit 1c0343f9d991c241d335712593f3a63858dc91b6. Reason: to make merging simpler. This feature will anyway be provided by master in a later version. --- py/malloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'py/malloc.c') diff --git a/py/malloc.c b/py/malloc.c index c837ed5735..b0493d9341 100644 --- a/py/malloc.c +++ b/py/malloc.c @@ -114,7 +114,10 @@ void *m_malloc_with_finaliser(size_t num_bytes) { void *m_malloc0(size_t num_bytes) { void *ptr = m_malloc(num_bytes); - // memory is already cleared by gc_alloc + if (ptr == NULL && num_bytes != 0) { + return m_malloc_fail(num_bytes); + } + memset(ptr, 0, num_bytes); return ptr; } -- cgit v1.2.3