summaryrefslogtreecommitdiff
path: root/usr/src/lib/libumem/common/malloc.c
diff options
context:
space:
mode:
authorjwadams <none@none>2005-10-28 09:59:07 -0700
committerjwadams <none@none>2005-10-28 09:59:07 -0700
commit87cd24809d33b40017e71ecba06bd30fc99fac6f (patch)
tree0241b0533c690b62feaa61cb8665c0a1f0003fc0 /usr/src/lib/libumem/common/malloc.c
parent37f3b9a4ce95e9d85bbf0a7e5ae2fd508f411fe0 (diff)
downloadillumos-joyent-87cd24809d33b40017e71ecba06bd30fc99fac6f.tar.gz
6341280 libumem's realloc() allocates when size is zero
Diffstat (limited to 'usr/src/lib/libumem/common/malloc.c')
-rw-r--r--usr/src/lib/libumem/common/malloc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr/src/lib/libumem/common/malloc.c b/usr/src/lib/libumem/common/malloc.c
index 41d394ff22..86c1b0fd0f 100644
--- a/usr/src/lib/libumem/common/malloc.c
+++ b/usr/src/lib/libumem/common/malloc.c
@@ -20,7 +20,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -394,6 +394,11 @@ realloc(void *buf_arg, size_t newsize)
if (buf_arg == NULL)
return (malloc(newsize));
+ if (newsize == 0) {
+ free(buf_arg);
+ return (NULL);
+ }
+
/*
* get the old data size without freeing the buffer
*/