setOrPadding增加重载,可选限制index大小

This commit is contained in:
Looly
2024-05-17 09:42:15 +08:00
parent 65ba22d34b
commit dcf66c8d93
4 changed files with 41 additions and 9 deletions

View File

@@ -455,7 +455,7 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
// issue#3286, 如果用户指定的index太大容易造成Java heap space错误。
if (!config.isIgnoreNullValue()) {
// issue#3286, 增加安全检查最多增加10倍
Validator.checkIndexLimit(index, this.size());
Validator.checkIndexLimit(index, (this.size() + 1) * 10);
while (index != this.size()) {
// 非末尾则填充null
this.add(null);