Skip to content
Permalink
Browse files

realloc(): fix possible memory leak

If size is equal to zero, and ptr is not NULL, then the call must be
equivalent to free(ptr).

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
  • Loading branch information...
Nicolas Pitre authored and andrewboie committed Jul 11, 2019
1 parent 92ddf63 commit ff7e4e69c8eeae6ec4bacc8478c34e3f927bd86a
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/libc/minimal/source/stdlib/malloc.c
@@ -96,6 +96,7 @@ void *realloc(void *ptr, size_t requested_size)
}

if (requested_size == 0) {
free(ptr);
return NULL;
}

0 comments on commit ff7e4e6

Please sign in to comment.
You can’t perform that action at this time.