From 87cd24809d33b40017e71ecba06bd30fc99fac6f Mon Sep 17 00:00:00 2001 From: jwadams Date: Fri, 28 Oct 2005 09:59:07 -0700 Subject: 6341280 libumem's realloc() allocates when size is zero --- usr/src/lib/libumem/common/malloc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'usr/src/lib/libumem/common/malloc.c') 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 */ -- cgit v1.2.3