mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-19 16:56:34 +00:00
Berry safeguard when freeing null pointer (#18735)
This commit is contained in:
parent
fe570a1b26
commit
b053cf87ec
@ -66,6 +66,7 @@ BERRY_API void* be_realloc(bvm *vm, void *ptr, size_t old_size, size_t new_size)
|
|||||||
|
|
||||||
/* Case 2: deallocate */
|
/* Case 2: deallocate */
|
||||||
else if (new_size == 0) {
|
else if (new_size == 0) {
|
||||||
|
if (ptr == NULL) { return NULL; } /* safeguard */
|
||||||
#if BE_USE_DEBUG_GC
|
#if BE_USE_DEBUG_GC
|
||||||
memset(ptr, 0xFF, old_size); /* fill the structure with invalid pointers */
|
memset(ptr, 0xFF, old_size); /* fill the structure with invalid pointers */
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user