From bcea2185485a81975e4ebebde90e219bc8f4bf4d Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Mon, 28 Sep 1992 13:43:23 +0000 Subject: (__builtin_new): Avoid passing 0 to malloc. From-SVN: r2267 --- gcc/libgcc2.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc') diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index a913c41..00c3909 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -1209,6 +1209,9 @@ __builtin_new (sz) { void *p; + /* malloc (0) is unpredictable; avoid it. */ + if (sz == 0) + sz = 1; p = (void *) malloc (sz); if (p == 0) (*__new_handler) (); -- cgit v1.1