Skip to content

Commit c5d1d21

Browse files
author
fangyidong
committed
Issue #12: Excessive memory consumption in parse() (contributed by glen.tw)
git-svn-id: http://json-simple.googlecode.com/svn/trunk@206 b68fe964-5755-0410-a06c-9fee2ea08261
1 parent 47b0867 commit c5d1d21

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

doc/json.lex

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ FALLBACK_CH = .
4646
}
4747
<STRING_BEGIN> \\ {sb.append('\\');}
4848

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

src/main/java/org/json/simple/parser/Yylex.java

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)