Skip to content
Permalink
Browse files

修复 #2689 字符串中包含\x转义字符时可能引发OOM的问题

  • Loading branch information...
Omega-Ariston committed Sep 3, 2019
1 parent 0c9bede commit 995845170527221ca0293cf290e33a7d6cb52bf7
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/main/java/com/alibaba/fastjson/parser/JSONLexerBase.java
@@ -973,6 +973,10 @@ public final void scanString() {
char x1 = ch = next();
char x2 = ch = next();

if (!isHexChar(x1) || !isHexChar(x2)) {
throw new JSONException("invalid escape character \\x" + x1 + x2);
}

int x_val = digits[x1] * 16 + digits[x2];
char x_char = (char) x_val;
putChar(x_char);
@@ -5033,6 +5037,10 @@ private void scanStringSingleQuote() {
this.next();
}

private boolean isHexChar(char ch) {
return ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'));
}

/**
* Append a character to sbuf.
*/

0 comments on commit 9958451

Please sign in to comment.
You can’t perform that action at this time.