From: ben Date: Tue, 13 Sep 2005 20:17:10 +0000 (+0000) Subject: When asked to malloc zero bytes, malloc one byte instead. This ensures X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/commitdiff_plain/66ab14c717d6954a7fa5986c02b685271c6b5b64 When asked to malloc zero bytes, malloc one byte instead. This ensures that we get a unique pointer rather than NULL (which ANSI C otherwise permits). Problem pointed out by Mike Protts. git-svn-id: svn://svn.tartarus.org/sgt/putty@6308 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/misc.c b/misc.c index 9d71a8d4..9c8d2039 100644 --- a/misc.c +++ b/misc.c @@ -441,6 +441,7 @@ void *safemalloc(size_t n, size_t size) p = NULL; } else { size *= n; + if (size == 0) size = 1; #ifdef MINEFIELD p = minefield_c_malloc(size); #else