mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复SONArray的add()方法抛出OutOfMemory异常问题
This commit is contained in:
@@ -457,6 +457,10 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
InternalJSONUtil.testValidity(element);
|
||||
this.rawList.add(index, JSONUtil.wrap(element, this.config));
|
||||
} else {
|
||||
// issue#3286, 增加安全检查,最多增加2倍
|
||||
if(index > (this.size() + 1) * 2) {
|
||||
throw new JSONException("Index is too large:", index);
|
||||
}
|
||||
while (index != this.size()) {
|
||||
this.add(JSONNull.NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user