libc: Check for NULL pointers in free()

POSIX says that the free() function should simply do nothing if a NULL
pointer argument has been specified. So let's be a little bit more
compliant in our libc and add a NULL pointer check here, too.

Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
Thomas Huth 2018-05-18 17:45:37 +02:00 committed by Alexey Kardashevskiy
parent f5825039ff
commit 232eb915d1
1 changed files with 3 additions and 1 deletions

View File

@ -19,8 +19,10 @@ free(void *ptr)
{
struct chunk *header;
if (!ptr)
return;
header = (struct chunk *) ptr;
header--;
header->inuse = 0;
}