From 3cdb65b4e15141e675cd7003f94f24b829422927 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 16 Sep 2014 07:31:32 -0700 Subject: Fix realloc related crash. Abort on error. --- man2html/man2html.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'man2html/man2html.c') diff --git a/man2html/man2html.c b/man2html/man2html.c index d3a0115..1a9309e 100644 --- a/man2html/man2html.c +++ b/man2html/man2html.c @@ -353,9 +353,12 @@ out_html(char *c) { } if (scaninbuff) { while (*c) { - if (buffpos >= buffmax) { - buffer = xrealloc(buffer, buffmax*2); - buffmax = buffmax*2; + while (buffpos >= buffmax) { + if (buffmax == 0) + buffmax = 32; + else + buffmax *= 2; + buffer = xrealloc(buffer, buffmax); } if (*c != '\a') buffer[buffpos++] = *c; @@ -3135,7 +3138,7 @@ error_page(char *s, char *t, ...) { vfprintf(stdout, t, p); va_end(p); printf("\n"); - exit(0); + abort(); } char * -- cgit v1.2.3