Berry safeguard when freeing null pointer (#18735)

This commit is contained in:
s-hadinger 2023-05-29 11:00:20 +02:00 committed by GitHub
parent fe570a1b26
commit b053cf87ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -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