]> granicus.if.org Git - yasm/commitdiff
Fix a few cases of freeing NULL pointers.
authorPeter Johnson <peter@tortall.net>
Wed, 7 Aug 2002 01:55:48 +0000 (01:55 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 7 Aug 2002 01:55:48 +0000 (01:55 -0000)
svn path=/trunk/yasm/; revision=662

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

index 1a9a3f66b85b0582f22c6773bab3323d8b6f4f29..1ce43d8d04d82ba2ada12e059e227bf1c1652a49 100644 (file)
@@ -1,10 +1,13 @@
-/* Generated by re2c 0.9.1-C on Mon Apr  8 22:47:58 2002 */
+/* Generated by re2c 0.9.1-C on Tue Aug  6 18:54:36 2002
+ */
 #line 1 "scanner.re"
+#include <config.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include "scanner.h"
+#include "parse.h"
 #include "parser.h"
-#include "y.tab.h"
 
 extern YYSTYPE yylval;
 
@@ -52,7 +55,8 @@ fill(Scanner *s, uchar *cursor)
            s->pos = &buf[s->pos - s->bot];
            s->lim = &buf[s->lim - s->bot];
            s->top = &s->lim[BSIZE];
-           free(s->bot);
+           if (s->bot)
+               free(s->bot);
            s->bot = buf;
        }
        if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){
@@ -63,7 +67,7 @@ fill(Scanner *s, uchar *cursor)
     return cursor;
 }
 
-#line 73
+#line 76
 
 
 int
@@ -86,11 +90,11 @@ yy2:        yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych == '*') goto yy7;
 yy3:
-#line 89
+#line 92
        { goto echo; }
 yy4:   yych = *++YYCURSOR;
 yy5:
-#line 85
+#line 88
        { if(cursor == s->eof) RETURN(0);
                                  fwrite(s->tok, 1, cursor - s->tok, out);
                                  s->tok = s->pos = cursor; s->cline++;
@@ -113,12 +117,12 @@ yy12:     yych = *++YYCURSOR;
        if(yych != 'c') goto yy8;
 yy13:  yych = *++YYCURSOR;
 yy14:
-#line 82
+#line 85
        { fwrite(s->tok, 1, &cursor[-7] - s->tok, out);
                                  s->tok = cursor;
                                  RETURN(1); }
 }
-#line 90
+#line 93
 
 }
 
@@ -188,32 +192,32 @@ yy15:
        }
 yy17:  yych = *++YYCURSOR;
 yy18:
-#line 105
+#line 108
        { depth = 1;
                                  goto code;
                                }
 yy19:  yych = *++YYCURSOR;
        if(yych == '*') goto yy54;
 yy20:
-#line 124
+#line 127
        { RETURN(*s->tok); }
 yy21:  yych = *++YYCURSOR;
        if(yych == '/') goto yy52;
 yy22:
-#line 126
+#line 129
        { yylval.op = *s->tok;
                                  RETURN(CLOSE); }
 yy23:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych != '\n')        goto yy48;
 yy24:
-#line 117
+#line 120
        { Scanner_fatal(s, "bad string"); }
 yy25:  yyaccept = 1;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych != '\n')        goto yy42;
 yy26:
-#line 122
+#line 125
        { Scanner_fatal(s, "bad character constant"); }
 yy27:  yych = *++YYCURSOR;
        goto yy20;
@@ -222,7 +226,7 @@ yy28:       yych = *++YYCURSOR;
 yy29:  yych = *++YYCURSOR;
        goto yy40;
 yy30:
-#line 129
+#line 132
        { SubStr substr;
                                  s->cur = cursor;
                                  substr = Scanner_token(s);
@@ -231,18 +235,18 @@ yy30:
 yy31:  yych = *++YYCURSOR;
        goto yy38;
 yy32:
-#line 135
+#line 138
        { goto scan; }
 yy33:  yych = *++YYCURSOR;
 yy34:
-#line 137
+#line 140
        { if(cursor == s->eof) RETURN(0);
                                  s->pos = cursor; s->cline++;
                                  goto scan;
                                }
 yy35:  yych = *++YYCURSOR;
 yy36:
-#line 142
+#line 145
        { fprintf(stderr, "unexpected character: '%c'\n", *s->tok);
                                  goto scan;
                                }
@@ -287,7 +291,7 @@ yy44:       ++YYCURSOR;
        goto yy41;
 yy45:  yych = *++YYCURSOR;
 yy46:
-#line 119
+#line 122
        { s->cur = cursor;
                                  yylval.regexp = ranToRE(Scanner_token(s));
                                  return RANGE; }
@@ -308,22 +312,22 @@ yy49:     ++YYCURSOR;
        goto yy47;
 yy50:  yych = *++YYCURSOR;
 yy51:
-#line 114
+#line 117
        { s->cur = cursor;
                                  yylval.regexp = strToRE(Scanner_token(s));
                                  return STRING; }
 yy52:  yych = *++YYCURSOR;
 yy53:
-#line 111
+#line 114
        { s->tok = cursor;
                                  RETURN(0); }
 yy54:  yych = *++YYCURSOR;
 yy55:
-#line 108
+#line 111
        { depth = 1;
                                  goto comment; }
 }
-#line 145
+#line 148
 
 
 code:
@@ -354,7 +358,7 @@ yy56:
        }
 yy58:  yych = *++YYCURSOR;
 yy59:
-#line 149
+#line 152
        { if(--depth == 0){
                                        s->cur = cursor;
                                        yylval.token = Token_new(Scanner_token(s), s->tline);
@@ -363,19 +367,19 @@ yy59:
                                  goto code; }
 yy60:  yych = *++YYCURSOR;
 yy61:
-#line 155
+#line 158
        { ++depth;
                                  goto code; }
 yy62:  yych = *++YYCURSOR;
 yy63:
-#line 157
+#line 160
        { if(cursor == s->eof) Scanner_fatal(s, "missing '}'");
                                  s->pos = cursor; s->cline++;
                                  goto code;
                                }
 yy64:  yych = *++YYCURSOR;
 yy65:
-#line 161
+#line 164
        { goto code; }
 yy66:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
@@ -420,7 +424,7 @@ yy74:       ++YYCURSOR;
        if(yych == '\n')        goto yy70;
        goto yy72;
 }
-#line 162
+#line 165
 
 
 comment:
@@ -443,14 +447,14 @@ yy75:
 yy77:  yych = *++YYCURSOR;
        if(yych == '/') goto yy85;
 yy78:
-#line 176
+#line 179
        { goto comment; }
 yy79:  yych = *++YYCURSOR;
        if(yych == '*') goto yy83;
        goto yy78;
 yy80:  yych = *++YYCURSOR;
 yy81:
-#line 172
+#line 175
        { if(cursor == s->eof) RETURN(0);
                                  s->tok = s->pos = cursor; s->cline++;
                                  goto comment;
@@ -459,18 +463,18 @@ yy82:     yych = *++YYCURSOR;
        goto yy78;
 yy83:  yych = *++YYCURSOR;
 yy84:
-#line 170
+#line 173
        { ++depth;
                                  goto comment; }
 yy85:  yych = *++YYCURSOR;
 yy86:
-#line 166
+#line 169
        { if(--depth == 0)
                                        goto scan;
                                    else
                                        goto comment; }
 }
-#line 177
+#line 180
 
 }
 
index aa6d50b377727a748b6aceb97375ad676ddb869a..23fdb9c789e488eb3587a73493628c5faeab43f5 100644 (file)
@@ -91,8 +91,10 @@ State_new(void)
 void
 State_delete(State *s)
 {
-    free(s->kernel);
-    free(s->go.span);
+    if (s->kernel)
+       free(s->kernel);
+    if (s->go.span)
+       free(s->go.span);
     free(s);
 }
 
index 6bca641dadd7254131b8a7f69fb11c4cfd8ac936..1ce43d8d04d82ba2ada12e059e227bf1c1652a49 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.1-C on Thu Apr 11 22:20:20 2002
+/* Generated by re2c 0.9.1-C on Tue Aug  6 18:54:36 2002
  */
 #line 1 "scanner.re"
 #include <config.h>
@@ -55,7 +55,8 @@ fill(Scanner *s, uchar *cursor)
            s->pos = &buf[s->pos - s->bot];
            s->lim = &buf[s->lim - s->bot];
            s->top = &s->lim[BSIZE];
-           free(s->bot);
+           if (s->bot)
+               free(s->bot);
            s->bot = buf;
        }
        if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){
@@ -66,7 +67,7 @@ fill(Scanner *s, uchar *cursor)
     return cursor;
 }
 
-#line 75
+#line 76
 
 
 int
@@ -89,11 +90,11 @@ yy2:        yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych == '*') goto yy7;
 yy3:
-#line 91
+#line 92
        { goto echo; }
 yy4:   yych = *++YYCURSOR;
 yy5:
-#line 87
+#line 88
        { if(cursor == s->eof) RETURN(0);
                                  fwrite(s->tok, 1, cursor - s->tok, out);
                                  s->tok = s->pos = cursor; s->cline++;
@@ -116,12 +117,12 @@ yy12:     yych = *++YYCURSOR;
        if(yych != 'c') goto yy8;
 yy13:  yych = *++YYCURSOR;
 yy14:
-#line 84
+#line 85
        { fwrite(s->tok, 1, &cursor[-7] - s->tok, out);
                                  s->tok = cursor;
                                  RETURN(1); }
 }
-#line 92
+#line 93
 
 }
 
@@ -191,32 +192,32 @@ yy15:
        }
 yy17:  yych = *++YYCURSOR;
 yy18:
-#line 107
+#line 108
        { depth = 1;
                                  goto code;
                                }
 yy19:  yych = *++YYCURSOR;
        if(yych == '*') goto yy54;
 yy20:
-#line 126
+#line 127
        { RETURN(*s->tok); }
 yy21:  yych = *++YYCURSOR;
        if(yych == '/') goto yy52;
 yy22:
-#line 128
+#line 129
        { yylval.op = *s->tok;
                                  RETURN(CLOSE); }
 yy23:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych != '\n')        goto yy48;
 yy24:
-#line 119
+#line 120
        { Scanner_fatal(s, "bad string"); }
 yy25:  yyaccept = 1;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych != '\n')        goto yy42;
 yy26:
-#line 124
+#line 125
        { Scanner_fatal(s, "bad character constant"); }
 yy27:  yych = *++YYCURSOR;
        goto yy20;
@@ -225,7 +226,7 @@ yy28:       yych = *++YYCURSOR;
 yy29:  yych = *++YYCURSOR;
        goto yy40;
 yy30:
-#line 131
+#line 132
        { SubStr substr;
                                  s->cur = cursor;
                                  substr = Scanner_token(s);
@@ -234,18 +235,18 @@ yy30:
 yy31:  yych = *++YYCURSOR;
        goto yy38;
 yy32:
-#line 137
+#line 138
        { goto scan; }
 yy33:  yych = *++YYCURSOR;
 yy34:
-#line 139
+#line 140
        { if(cursor == s->eof) RETURN(0);
                                  s->pos = cursor; s->cline++;
                                  goto scan;
                                }
 yy35:  yych = *++YYCURSOR;
 yy36:
-#line 144
+#line 145
        { fprintf(stderr, "unexpected character: '%c'\n", *s->tok);
                                  goto scan;
                                }
@@ -290,7 +291,7 @@ yy44:       ++YYCURSOR;
        goto yy41;
 yy45:  yych = *++YYCURSOR;
 yy46:
-#line 121
+#line 122
        { s->cur = cursor;
                                  yylval.regexp = ranToRE(Scanner_token(s));
                                  return RANGE; }
@@ -311,22 +312,22 @@ yy49:     ++YYCURSOR;
        goto yy47;
 yy50:  yych = *++YYCURSOR;
 yy51:
-#line 116
+#line 117
        { s->cur = cursor;
                                  yylval.regexp = strToRE(Scanner_token(s));
                                  return STRING; }
 yy52:  yych = *++YYCURSOR;
 yy53:
-#line 113
+#line 114
        { s->tok = cursor;
                                  RETURN(0); }
 yy54:  yych = *++YYCURSOR;
 yy55:
-#line 110
+#line 111
        { depth = 1;
                                  goto comment; }
 }
-#line 147
+#line 148
 
 
 code:
@@ -357,7 +358,7 @@ yy56:
        }
 yy58:  yych = *++YYCURSOR;
 yy59:
-#line 151
+#line 152
        { if(--depth == 0){
                                        s->cur = cursor;
                                        yylval.token = Token_new(Scanner_token(s), s->tline);
@@ -366,19 +367,19 @@ yy59:
                                  goto code; }
 yy60:  yych = *++YYCURSOR;
 yy61:
-#line 157
+#line 158
        { ++depth;
                                  goto code; }
 yy62:  yych = *++YYCURSOR;
 yy63:
-#line 159
+#line 160
        { if(cursor == s->eof) Scanner_fatal(s, "missing '}'");
                                  s->pos = cursor; s->cline++;
                                  goto code;
                                }
 yy64:  yych = *++YYCURSOR;
 yy65:
-#line 163
+#line 164
        { goto code; }
 yy66:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
@@ -423,7 +424,7 @@ yy74:       ++YYCURSOR;
        if(yych == '\n')        goto yy70;
        goto yy72;
 }
-#line 164
+#line 165
 
 
 comment:
@@ -446,14 +447,14 @@ yy75:
 yy77:  yych = *++YYCURSOR;
        if(yych == '/') goto yy85;
 yy78:
-#line 178
+#line 179
        { goto comment; }
 yy79:  yych = *++YYCURSOR;
        if(yych == '*') goto yy83;
        goto yy78;
 yy80:  yych = *++YYCURSOR;
 yy81:
-#line 174
+#line 175
        { if(cursor == s->eof) RETURN(0);
                                  s->tok = s->pos = cursor; s->cline++;
                                  goto comment;
@@ -462,18 +463,18 @@ yy82:     yych = *++YYCURSOR;
        goto yy78;
 yy83:  yych = *++YYCURSOR;
 yy84:
-#line 172
+#line 173
        { ++depth;
                                  goto comment; }
 yy85:  yych = *++YYCURSOR;
 yy86:
-#line 168
+#line 169
        { if(--depth == 0)
                                        goto scan;
                                    else
                                        goto comment; }
 }
-#line 179
+#line 180
 
 }
 
index 2cd32ed9e6560f12d6096a4155d8919d147b0ef4..cf69c590b6a25d3375b073830e35c695b005c4bc 100644 (file)
@@ -52,7 +52,8 @@ fill(Scanner *s, uchar *cursor)
            s->pos = &buf[s->pos - s->bot];
            s->lim = &buf[s->lim - s->bot];
            s->top = &s->lim[BSIZE];
-           free(s->bot);
+           if (s->bot)
+               free(s->bot);
            s->bot = buf;
        }
        if((cnt = fread(s->lim, sizeof(uchar), BSIZE, s->in)) != BSIZE){