From: Peter Johnson Date: Fri, 25 Apr 2008 01:58:59 +0000 (-0000) Subject: Fix some re2c memory/initialization issues. X-Git-Tag: v0.7.2~7^2~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0423a89a790af79f4eb0063416ce5c9a139bc168;p=yasm Fix some re2c memory/initialization issues. Found by: valgrind svn path=/trunk/yasm/; revision=2072 --- diff --git a/tools/re2c/dfa.c b/tools/re2c/dfa.c index e54deecc..16509de2 100644 --- a/tools/re2c/dfa.c +++ b/tools/re2c/dfa.c @@ -76,10 +76,14 @@ State * State_new(void) { State *s = malloc(sizeof(State)); + s->label = 0; s->rule = NULL; + s->next = NULL; s->link = NULL; + s->depth = 0; s->kCount = 0; s->kernel = NULL; + s->isBase = 0; s->action = NULL; s->go.nSpans = 0; s->go.span = NULL; diff --git a/tools/re2c/scanner.c b/tools/re2c/scanner.c index 4640ee4a..034c935b 100644 --- a/tools/re2c/scanner.c +++ b/tools/re2c/scanner.c @@ -48,7 +48,7 @@ fill(Scanner *s, unsigned char *cursor) s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE)); + unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE) + 1); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; diff --git a/tools/re2c/scanner.re b/tools/re2c/scanner.re index 10af0883..423835b6 100644 --- a/tools/re2c/scanner.re +++ b/tools/re2c/scanner.re @@ -45,7 +45,7 @@ fill(Scanner *s, unsigned char *cursor) s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE)); + unsigned char *buf = malloc(((s->lim - s->bot) + BSIZE) + 1); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot];