From: dtrg Date: Fri, 21 Jul 2006 09:28:36 +0000 (+0000) Subject: Rearranged the algorithm in get_text() to fix a memory overrun. X-Git-Tag: release-6-0-pre-1~113 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=685e85002e093865ae6028e9123bbd250a09a751;p=ack.git Rearranged the algorithm in get_text() to fix a memory overrun. --- diff --git a/util/cpp/domacro.c b/util/cpp/domacro.c index 4ef021f9d..5fd71eba5 100644 --- a/util/cpp/domacro.c +++ b/util/cpp/domacro.c @@ -608,7 +608,6 @@ get_text(formals, length) register unsigned int text_size; char *text = Malloc(text_size = ITEXTSIZE); register unsigned int pos = 0; - int match = 0; LoadChar(c); @@ -622,19 +621,15 @@ get_text(formals, length) */ text[pos++] = ' '; ++LineNumber; + LoadChar(c); } - else { + else text[pos++] = '\\'; - if (pos == text_size) - text = Realloc(text, text_size <<= 1); - text[pos++] = c; - if (pos == text_size) - text = Realloc(text, text_size <<= 1); - } - LoadChar(c); + if (pos == text_size) + text = Realloc(text, text_size <<= 1); } else - if (match == 0 && c == '/') { + if ( c == '/') { LoadChar(c); if (c == '*') { skipcomment(); @@ -647,19 +642,7 @@ get_text(formals, length) text = Realloc(text, text_size <<= 1); } else - if (c == '\'' || c == '"') { - text[pos++] = c; - if (pos == text_size) - text = Realloc(text, text_size <<= 1); - if (match == c) { - match = 0; - } else if (match == 0) { - match = c; - } - LoadChar(c); - } - else - if (match == 0 && formals && class(c) == STIDF) { + if (formals && class(c) == STIDF) { char id_buf[IDFSIZE + 1]; register char *idp = id_buf; int n;