浏览代码

Update malloc behavior on malloc(0) to be consistant with
malloc-930716 behavior, i.e. return a NULL.

Eric Andersen 22 年之前
父节点
当前提交
a018fc5564
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      libc/stdlib/malloc/malloc.c

+ 5 - 2
libc/stdlib/malloc/malloc.c

@@ -1,8 +1,8 @@
 /*
 /*
  * libc/stdlib/malloc/malloc.c -- malloc function
  * libc/stdlib/malloc/malloc.c -- malloc function
  *
  *
- *  Copyright (C) 2002  NEC Corporation
+ *  Copyright (C) 2002,03  NEC Electronics Corporation
- *  Copyright (C) 2002  Miles Bader <miles@gnu.org>
+ *  Copyright (C) 2002,03  Miles Bader <miles@gnu.org>
  *
  *
  * This file is subject to the terms and conditions of the GNU Lesser
  * This file is subject to the terms and conditions of the GNU Lesser
  * General Public License.  See the file COPYING.LIB in the main
  * General Public License.  See the file COPYING.LIB in the main
@@ -184,5 +184,8 @@ malloc (size_t size)
     __heap_check (&__malloc_heap, "malloc");
     __heap_check (&__malloc_heap, "malloc");
 #endif
 #endif
 
 
+  if (size == 0)
+    return 0;
+
   return malloc_from_heap (size, &__malloc_heap);
   return malloc_from_heap (size, &__malloc_heap);
 }
 }