]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR preprocessor/9465 (tradcpp0 segfaults on nul bytes)
authorJakub Jelinek <jakub@redhat.com>
Sun, 2 Feb 2003 12:59:58 +0000 (13:59 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 2 Feb 2003 12:59:58 +0000 (13:59 +0100)
PR preprocessor/9465
* tradcpp.c (fixup_newlines): Use memchr instead of strchr.

From-SVN: r62280

gcc/ChangeLog
gcc/tradcpp.c

index 36d3b5bd00d06e1102dbd9761b02c5bac23a2870..f8e0536229f8523303756f2092c2943ff1423761 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR preprocessor/9465
+       * tradcpp.c (fixup_newlines): Use memchr instead of strchr.
+
 2003-01-31  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa.c (pa_output_function_prologue, pa_output_function_epilogue): Move
index 979179cb10bf0b47419fda20ae01cad4e3da5744..f277eba0ee0b9d7d38d212dd70cf5371d5c40267 100644 (file)
@@ -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')