From 2d2a86ae7990763ce93c342c8557cfec515f7003 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 2 May 2001 22:50:01 +0200 Subject: [PATCH] tradcpp.c (do_define): Make sure we don't walk past limit. * tradcpp.c (do_define): Make sure we don't walk past limit. * gcc.dg/cpp/tr-define.c: New test. From-SVN: r41773 --- gcc/ChangeLog | 4 ++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/cpp/tr-define.c | 2 ++ gcc/tradcpp.c | 6 +++--- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cpp/tr-define.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 83ca906c43d..301de81d4c3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2001-05-02 Jakub Jelinek + + * tradcpp.c (do_define): Make sure we don't walk past limit. + 2000-05-01 Franz Sirl * config/rs6000/rs6000.c (rs6000_legitimate_address): Allow any stack diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e99ee8480a7..af464e59bff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-05-02 Jakub Jelinek + + * gcc.dg/cpp/tr-define.c: New test. + 2001-05-01 Loren J. Rittle * g++.old-deja/g++.abi/cxa_vec.C: Get malloc() from diff --git a/gcc/testsuite/gcc.dg/cpp/tr-define.c b/gcc/testsuite/gcc.dg/cpp/tr-define.c new file mode 100644 index 00000000000..54bd7a73b3b --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/tr-define.c @@ -0,0 +1,2 @@ +/* { dg-do preprocess } */ +/* { dg-options "-traditional -DDEFINE1DEFINE -DDEFINE2DEFIN=" } */ diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c index d5674736f47..bfb12027b83 100644 --- a/gcc/tradcpp.c +++ b/gcc/tradcpp.c @@ -2670,8 +2670,8 @@ do_define (buf, limit, op) } } - ++bp; /* skip paren */ - while (is_nvspace (*bp)) /* and leading whitespace */ + ++bp; /* skip paren */ + while (is_nvspace (*bp) && bp < limit) /* and leading whitespace */ ++bp; /* now everything from bp before limit is the definition. */ defn = collect_expansion (bp, limit, argno, arg_ptrs); @@ -2698,7 +2698,7 @@ do_define (buf, limit, op) } } else { /* simple expansion or empty definition; skip leading whitespace */ - while (is_nvspace (*bp)) + while (is_nvspace (*bp) && bp < limit) ++bp; /* now everything from bp before limit is the definition. */ defn = collect_expansion (bp, limit, -1, 0); -- 2.30.2