From 153a2c8018b499cbb5eb5acf59ff1c8d4c055d0b Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Thu, 9 Mar 2023 01:57:57 -0700 Subject: [PATCH] Handle corrupt classfiles more robustly (#758) --- .../java/io/github/classgraph/TypeArgument.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/classgraph/TypeArgument.java b/src/main/java/io/github/classgraph/TypeArgument.java index 302d57034..8050cf9eb 100644 --- a/src/main/java/io/github/classgraph/TypeArgument.java +++ b/src/main/java/io/github/classgraph/TypeArgument.java @@ -103,11 +103,17 @@ protected void addTypeAnnotation(final List typePath, final Annota // Annotation before wildcard addTypeAnnotation(annotationInfo); } else if (typePath.size() > 0 && typePath.get(0).typePathKind == 2) { - // Annotation is on the bound of a wildcard type argument of a parameterized type - typeSignature.addTypeAnnotation(typePath.subList(1, typePath.size()), annotationInfo); + // Annotation is on the bound of a wildcard type argument of a parameterized type. + // TypeSignature can be null in a corrupt classfile (#758). + if (typeSignature != null) { + typeSignature.addTypeAnnotation(typePath.subList(1, typePath.size()), annotationInfo); + } } else { - // Annotation is on a type argument of a parameterized type - typeSignature.addTypeAnnotation(typePath, annotationInfo); + // Annotation is on a type argument of a parameterized type. + // TypeSignature can be null in a corrupt classfile (#758). + if (typeSignature != null) { + typeSignature.addTypeAnnotation(typePath, annotationInfo); + } } }