This commit is contained in:
Looly 2023-08-30 21:57:28 +08:00
parent 5c2a48fee4
commit a3efec9c52

View File

@ -456,12 +456,13 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
} }
this.rawList.add(index, InternalJSONUtil.wrap(element, this.config)); this.rawList.add(index, InternalJSONUtil.wrap(element, this.config));
} else { } else {
if (!config.isIgnoreNullValue()) { // issue#3286, 如果用户指定的index太大容易造成Java heap space错误
while (index != this.size()) { // if (!config.isIgnoreNullValue()) {
// 非末尾则填充null // while (index != this.size()) {
this.add(null); // // 非末尾则填充null
} // this.add(null);
} // }
// }
this.add(element); this.add(element);
} }