]> granicus.if.org Git - yasm/commitdiff
Fix some re2c memory/initialization issues.
authorPeter Johnson <peter@tortall.net>
Fri, 25 Apr 2008 01:58:59 +0000 (01:58 -0000)
committerPeter Johnson <peter@tortall.net>
Fri, 25 Apr 2008 01:58:59 +0000 (01:58 -0000)
Found by: valgrind

svn path=/trunk/yasm/; revision=2072

tools/re2c/dfa.c
tools/re2c/scanner.c
tools/re2c/scanner.re

index e54deecc1a6dda9634b77d0fff8ec2812556839c..16509de2a9185d2597dd1458698df4413ebbbcfb 100644 (file)
@@ -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;
index 4640ee4ad02e72e4a12ec4debec6c551f5966223..034c935bd9067b3cdea31cacd62e24d4fd98d6d4 100644 (file)
@@ -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];
index 10af0883ed288f0e00f75531dffc61afcce07328..423835b6c0299e1adde98dc78e551f91696578b7 100644 (file)
@@ -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];