From: Jakub Jelinek Date: Sun, 2 Feb 2003 12:59:58 +0000 (+0100) Subject: re PR preprocessor/9465 (tradcpp0 segfaults on nul bytes) X-Git-Tag: releases/gcc-3.2.2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d5c9565cda5c5ad567d25382bc79cd51d66a756;p=thirdparty%2Fgcc.git re PR preprocessor/9465 (tradcpp0 segfaults on nul bytes) PR preprocessor/9465 * tradcpp.c (fixup_newlines): Use memchr instead of strchr. From-SVN: r62280 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 36d3b5bd00d0..f8e0536229f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-02-01 Jakub Jelinek + + PR preprocessor/9465 + * tradcpp.c (fixup_newlines): Use memchr instead of strchr. + 2003-01-31 John David Anglin * pa.c (pa_output_function_prologue, pa_output_function_epilogue): Move diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c index 979179cb10bf..f277eba0ee0b 100644 --- a/gcc/tradcpp.c +++ b/gcc/tradcpp.c @@ -1,5 +1,5 @@ /* C Compatible Compiler Preprocessor (CCCP) -Copyright (C) 1986, 1987, 1989, 2000, 2001 Free Software Foundation, Inc. +Copyright (C) 1986, 1987, 1989, 2000, 2001, 2003 Free Software Foundation, Inc. Written by Paul Rubin, June 1986 Adapted to ANSI C, Richard Stallman, Jan 1987 Dusted off, polished, and adapted for use as traditional @@ -2604,10 +2604,8 @@ fixup_newlines (fp) return; end = fp->buf + fp->length; - *end = '\r'; - p = (U_CHAR *) strchr ((const char *) fp->buf, '\r'); - *end = '\0'; - if (p == end) + p = (U_CHAR *) memchr ((const char *) fp->buf, '\r', fp->length); + if (p == NULL) return; if (p > fp->buf && p[-1] == '\n')