This repository was archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
util/FieldInfo.java 里 getInheritGenericType() 可疑的空指针解引用 #1614
Copy link
Copy link
Closed
Description
Hi,
我们的代码检查器 Pinpoint 报告了一处可疑的空指针解引用,
fastjson/src/main/java/com/alibaba/fastjson/util/FieldInfo.java
Lines 349 to 378 in fcd2ae7
| if (gd instanceof Class) { | |
| class_gd = (Class<?>) tv.getGenericDeclaration(); | |
| } | |
| Type[] arguments = null; | |
| if (class_gd == clazz) { | |
| if (type instanceof ParameterizedType) { | |
| ParameterizedType ptype = (ParameterizedType) type; | |
| arguments = ptype.getActualTypeArguments(); | |
| } | |
| } else { | |
| for (Class<?> c = clazz; c != null && c != Object.class && c != class_gd; c = c.getSuperclass()) { | |
| Type superType = c.getGenericSuperclass(); | |
| if (superType instanceof ParameterizedType) { | |
| ParameterizedType p_superType = (ParameterizedType) superType; | |
| Type[] p_superType_args = p_superType.getActualTypeArguments(); | |
| getArgument(p_superType_args, c.getTypeParameters(), arguments); | |
| arguments = p_superType_args; | |
| } | |
| } | |
| } | |
| if (arguments == null) { | |
| return null; | |
| } | |
| Type actualType = null; | |
| TypeVariable<?>[] typeVariables = class_gd.getTypeParameters(); | |
| for (int j = 0; j < typeVariables.length; ++j) { |
349 行是否可能返回 false,导致 377 行使用 class_gd 时触发空指针解引用?
祝好,
Sourcebrella Inc.
Reactions are currently unavailable