ABC Explorer - Try to avoid index out of bounds

This commit is contained in:
Jindra Petřík
2023-09-29 20:18:00 +02:00
parent e17fcb8d5f
commit c58c1f6bfa
2 changed files with 9 additions and 0 deletions

View File

@@ -254,6 +254,9 @@ public class Multiname {
if (index == 0) {
return "null";
}
if (index >= constants.getNamespaceCount()) {
return "Unknown(" + index + ")";
}
int type = constants.getNamespace(index).kind;
int name_index = constants.getNamespace(index).name_index;
String name = name_index == 0 ? null : constants.getNamespace(index).getName(constants).toRawString();
@@ -273,6 +276,9 @@ public class Multiname {
if (index == 0) {
return "null";
}
if (index >= constants.getNamespaceSetCount()) {
return "Unknown(" + index + ")";
}
StringBuilder ret = new StringBuilder();
ret.append("[");
for (int n = 0; n < constants.getNamespaceSet(index).namespaces.length; n++) {

View File

@@ -74,6 +74,9 @@ public class ScriptInfo {
for (int j = 0; j < traits.traits.size(); j++) {
Trait t = traits.traits.get(j);
if (t.name_index >= abc.constants.getMultinameCount()) {
continue;
}
Multiname name = t.getName(abc);
int nskind = name.getSimpleNamespaceKind(abc.constants);
if ((nskind == Namespace.KIND_PACKAGE_INTERNAL)