aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2018-05-18 17:45:37 +0200
committerAlexey Kardashevskiy <aik@ozlabs.ru>2018-05-24 19:03:53 +1000
commit232eb915d1c08de17c59a05557ea6051275d078b (patch)
tree86c88081e7e9c335fcd0fe02cd6f1fbb2b9ed448 /lib
parentf5825039ffed4508f07abda271ec836a3fa43bf4 (diff)
downloadSLOF-232eb915d1c08de17c59a05557ea6051275d078b.zip
SLOF-232eb915d1c08de17c59a05557ea6051275d078b.tar.gz
SLOF-232eb915d1c08de17c59a05557ea6051275d078b.tar.bz2
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/free.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/stdlib/free.c b/lib/libc/stdlib/free.c
index 9005450..d276585 100644
--- a/lib/libc/stdlib/free.c
+++ b/lib/libc/stdlib/free.c
@@ -19,8 +19,10 @@ free(void *ptr)
{
struct chunk *header;
+ if (!ptr)
+ return;
+
header = (struct chunk *) ptr;
header--;
header->inuse = 0;
-
}