diff options
author | 2015-09-14 17:34:03 +0000 | |
---|---|---|
committer | 2015-09-14 17:34:03 +0000 | |
commit | 7578198aab3def299aedd4e2418c1768fd8fe080 (patch) | |
tree | d5ae8a522f97cc34dcca55ab6d48dc5edad7d511 /sys/lib/libsa/alloc.c | |
parent | convert .Fd #include to .In (diff) | |
download | wireguard-openbsd-7578198aab3def299aedd4e2418c1768fd8fe080.tar.xz wireguard-openbsd-7578198aab3def299aedd4e2418c1768fd8fe080.zip |
unify free(NULL,size) behaviour by allowing passing NULL
ok millert@ jasper@
Diffstat (limited to 'sys/lib/libsa/alloc.c')
-rw-r--r-- | sys/lib/libsa/alloc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/lib/libsa/alloc.c b/sys/lib/libsa/alloc.c index 64f8a0bc643..1714ec06600 100644 --- a/sys/lib/libsa/alloc.c +++ b/sys/lib/libsa/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.10 2009/05/14 18:54:03 miod Exp $ */ +/* $OpenBSD: alloc.c,v 1.11 2015/09/14 17:34:04 semarie Exp $ */ /* $NetBSD: alloc.c,v 1.6 1997/02/04 18:36:33 thorpej Exp $ */ /* @@ -213,8 +213,12 @@ found: void free(void *ptr, unsigned int size) { - struct fl *f = (struct fl *)((char *)ptr - - ALIGN(sizeof(unsigned))); + struct fl *f; + + if (ptr == NULL) + return; + + f = (struct fl *)((char *)ptr - ALIGN(sizeof(unsigned))); #ifdef ALLOC_TRACE printf("free(%p, %u) (origsize %u)\n", ptr, size, f->size); |