Issue #12: Excessive memory consumption in parse() (contributed by glen.tw)

This commit is contained in:
fangyidong
2012-05-16 13:51:15 +00:00
parent c00dc27433
commit 0353e4c196
2 changed files with 3 additions and 3 deletions

View File

@@ -46,7 +46,7 @@ FALLBACK_CH = .
}
<STRING_BEGIN> \\ {sb.append('\\');}
<YYINITIAL> \" { sb.delete(0, sb.length());yybegin(STRING_BEGIN);}
<YYINITIAL> \" { sb = null; sb = new StringBuffer(); yybegin(STRING_BEGIN);}
<YYINITIAL> {INT} { Long val=Long.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);}
<YYINITIAL> {DOUBLE} { Double val=Double.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);}
<YYINITIAL> "true"|"false" { Boolean val=Boolean.valueOf(yytext()); return new Yytoken(Yytoken.TYPE_VALUE, val);}
@@ -58,4 +58,4 @@ FALLBACK_CH = .
<YYINITIAL> "," { return new Yytoken(Yytoken.TYPE_COMMA,null);}
<YYINITIAL> ":" { return new Yytoken(Yytoken.TYPE_COLON,null);}
<YYINITIAL> {WS}+ {}
<YYINITIAL> {FALLBACK_CH} { throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_CHAR, new Character(yycharat(0)));}
<YYINITIAL> {FALLBACK_CH} { throw new ParseException(yychar, ParseException.ERROR_UNEXPECTED_CHAR, new Character(yycharat(0)));}

View File

@@ -575,7 +575,7 @@ int getPosition(){
}
case 25: break;
case 4:
{ sb.delete(0, sb.length());yybegin(STRING_BEGIN);
{ sb = null; sb = new StringBuffer(); yybegin(STRING_BEGIN);
}
case 26: break;
case 16: