From 2e292fba6f1e3e53c5a230dc9cb69db5463983b3 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Sun, 2 Jan 2011 10:56:57 +0300 I had an empty "Makefile,v" and csup choked on it, entering the infinite cycle and grabbing memory. The problem is that the 'ID' was defined as 0 and the built-in YY_NULL that tells the caller that EOF was found is 0 too. So, the following cycle on the empty file will be infinite: {{{ /* access {id]*; */ assert(token == KEYWORD); token = rcslex(*sp); while (token == ID) { id = duptext(sp, NULL); rcsfile_addaccess(rf, id); free(id); token = rcslex(*sp); } }}} Signed-off-by: Eygene Ryabinkin --- usr.bin/csup/rcsparse.h | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/usr.bin/csup/rcsparse.h b/usr.bin/csup/rcsparse.h index 01b0156..3701407 100644 --- a/usr.bin/csup/rcsparse.h +++ b/usr.bin/csup/rcsparse.h @@ -28,13 +28,14 @@ #ifndef _RCSPARSE_H_ #define _RCSPARSE_H_ -#define ID 0 -#define NUM 1 -#define KEYWORD 2 -#define KEYWORD_TWO 3 -#define STRING 4 -#define SEMIC 5 -#define COLON 6 +/* NB: YY_NULL that signifies the EOF condition is 0: don't use it here. */ +#define ID 1 +#define NUM 2 +#define KEYWORD 3 +#define KEYWORD_TWO 4 +#define STRING 5 +#define SEMIC 6 +#define COLON 7 struct rcsfile; int rcsparse_run(struct rcsfile *, FILE *, int); -- 1.7.3.2