From a32e68b8c4179b33963fd80dc9cfa03c75b79d52 Mon Sep 17 00:00:00 2001 From: zhuangdeshuai <32005730+zhuangdeshuai@users.noreply.github.com> Date: Wed, 3 Jan 2024 19:22:33 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=20fastjson2=20?= =?UTF-8?q?=E5=9C=A8=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E5=AD=98=E5=9C=A8=E5=BC=95=E7=94=A8=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=E6=97=B6=EF=BC=8C=E5=AD=98=E5=9C=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C=E6=88=96=E8=80=85=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98=20(#2149?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] 修复 fastjson2 在反序列化列表对象存在引用关系时,存在数据数组越界或者数据丢失的问题 --- core/src/main/java/com/alibaba/fastjson2/JSONReader.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java index 1fdb877463..09d4283a16 100644 --- a/core/src/main/java/com/alibaba/fastjson2/JSONReader.java +++ b/core/src/main/java/com/alibaba/fastjson2/JSONReader.java @@ -451,7 +451,11 @@ public final void handleResolveTasks(Object root) { if (index == list.size()) { list.add(fieldValue); } else { - list.set(index, fieldValue); + if (index < list.size() && list.get(index) == null) { + list.set(index, fieldValue); + } else { + list.add(index, fieldValue); + } } continue; }