X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fxmalloc.c;h=3b5f86cdca11571c5326d9833d3597413e3e4425;hb=ab624c1a8f744419fdb653b77250153a3563203f;hp=74a8614b6c539b93efd949fd8db6d7fd4d4ad7e3;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 74a8614b6..3b5f86cdc 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -1,6 +1,6 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-2000, 2002-2006, 2008-2011 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -52,8 +52,16 @@ xmalloc (size_t n) void * xrealloc (void *p, size_t n) { + if (!n && p) + { + /* The GNU and C99 realloc behaviors disagree here. Act like + GNU, even if the underlying realloc is C99. */ + free (p); + return NULL; + } + p = realloc (p, n); - if (!p && n != 0) + if (!p && n) xalloc_die (); return p; }