From 2dd2e62273983693076360e1bc4e59a0f9184c68 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 2 Dec 2012 15:11:42 -0800 Subject: Fix xpalloc confusion after memory is exhausted. * alloc.c (xpalloc): Comment fix. * charset.c (Fdefine_charset_internal): If xpalloc exhausts memory and signals an error, do not clear charset_table_size, as charset_table is still valid. * doprnt.c (evxprintf): Clear *BUF after freeing it. --- src/doprnt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/doprnt.c') diff --git a/src/doprnt.c b/src/doprnt.c index caa56d6ae88..8cab219aafa 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -521,7 +521,10 @@ evxprintf (char **buf, ptrdiff_t *bufsize, if (nbytes < *bufsize - 1) return nbytes; if (*buf != nonheapbuf) - xfree (*buf); + { + xfree (*buf); + *buf = NULL; + } *buf = xpalloc (NULL, bufsize, 1, bufsize_max, 1); } } -- cgit v1.2.1