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>
This commit is contained in:
parent
92ddf63cb8
commit
ff7e4e69c8
1 changed files with 1 additions and 0 deletions
|
@ -96,6 +96,7 @@ void *realloc(void *ptr, size_t requested_size)
|
|||
}
|
||||
|
||||
if (requested_size == 0) {
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue