summaryrefslogtreecommitdiffstatshomepage
path: root/py/malloc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-08-14 12:14:05 +1000
committerDamien George <damien.p.george@gmail.com>2017-08-14 12:14:05 +1000
commitb4078cbbf3354229fc81ecfd26295237d808caa9 (patch)
tree304ecf0b425fe9aeddef30925134ef80346be084 /py/malloc.c
parente52758da223e57b6cd9458f039f8ccc50ee76ddb (diff)
downloadmicropython-b4078cbbf3354229fc81ecfd26295237d808caa9.tar.gz
micropython-b4078cbbf3354229fc81ecfd26295237d808caa9.zip
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.
Diffstat (limited to 'py/malloc.c')
-rw-r--r--py/malloc.c5
1 files changed, 4 insertions, 1 deletions
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;
}