Commit c5994f95 authored by Skylot's avatar Skylot

core: fix NPE in signature parser (#313)

parent 03a09deb
...@@ -192,23 +192,23 @@ public class ClassNode extends LineAttrNode implements ILoadable, IDexNode { ...@@ -192,23 +192,23 @@ public class ClassNode extends LineAttrNode implements ILoadable, IDexNode {
break; break;
} }
} }
} catch (JadxRuntimeException e) { } catch (Exception e) {
LOG.error("Class signature parse error: {}", this, e); LOG.error("Class signature parse error: {}", this, e);
} }
} }
private void setFieldsTypesFromSignature() { private void setFieldsTypesFromSignature() {
for (FieldNode field : fields) { for (FieldNode field : fields) {
SignatureParser sp = SignatureParser.fromNode(field); try {
if (sp != null) { SignatureParser sp = SignatureParser.fromNode(field);
try { if (sp != null) {
ArgType gType = sp.consumeType(); ArgType gType = sp.consumeType();
if (gType != null) { if (gType != null) {
field.setType(gType); field.setType(gType);
} }
} catch (JadxRuntimeException e) {
LOG.error("Field signature parse error: {}", field, e);
} }
} catch (Exception e) {
LOG.error("Field signature parse error: {}.{}", this.getFullName(), field.getName(), e);
} }
} }
} }
......
...@@ -180,6 +180,9 @@ public class SignatureParser { ...@@ -180,6 +180,9 @@ public class SignatureParser {
next(); next();
// type parsing not completed, proceed to inner class // type parsing not completed, proceed to inner class
ArgType inner = consumeObjectType(true); ArgType inner = consumeObjectType(true);
if (inner == null) {
throw new JadxRuntimeException("No inner type found: " + debugString());
}
return ArgType.genericInner(genericType, inner.getObject(), inner.getGenericTypes()); return ArgType.genericInner(genericType, inner.getObject(), inner.getGenericTypes());
} else { } else {
consume(';'); consume(';');
...@@ -289,6 +292,9 @@ public class SignatureParser { ...@@ -289,6 +292,9 @@ public class SignatureParser {
} }
private String debugString() { private String debugString() {
if (pos >= sign.length()) {
return sign;
}
return sign + " at position " + pos + " ('" + sign.charAt(pos) + "')"; return sign + " at position " + pos + " ('" + sign.charAt(pos) + "')";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment