From b053cf87ece5eb14b013c51ab457fe372d5a153c Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Mon, 29 May 2023 11:00:20 +0200 Subject: [PATCH] Berry safeguard when freeing null pointer (#18735) --- lib/libesp32/berry/src/be_mem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libesp32/berry/src/be_mem.c b/lib/libesp32/berry/src/be_mem.c index 976afece1..3657fd951 100644 --- a/lib/libesp32/berry/src/be_mem.c +++ b/lib/libesp32/berry/src/be_mem.c @@ -66,6 +66,7 @@ BERRY_API void* be_realloc(bvm *vm, void *ptr, size_t old_size, size_t new_size) /* Case 2: deallocate */ else if (new_size == 0) { + if (ptr == NULL) { return NULL; } /* safeguard */ #if BE_USE_DEBUG_GC memset(ptr, 0xFF, old_size); /* fill the structure with invalid pointers */ #endif