Skip to content

Commit

Permalink
[bugfix] Avoid IndexOutOfBoundsException
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Oct 10, 2024
1 parent 6707e2a commit e2fba83
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exist-core/src/main/java/org/exist/xquery/value/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ public static boolean subTypeOf(int subtype, final int supertype) {
*
* @param subtype type code of the sub type
* @return type constant for the super type
*
* @throws IllegalArgumentException if {@code subtype} has no defined super type
*/
public static int getSuperType(final int subtype) {
if (subtype == ITEM || subtype == NODE) {
Expand All @@ -559,6 +561,11 @@ public static int getSuperType(final int subtype) {
return subtype;
}

if (subtype >= superTypes.length) {
// Note that EMPTY_SEQUENCE is *not* a sub-type of anything else than itself
throw new IllegalArgumentException("Type: " + subtype + " has no super types defined");
}

final int supertype = superTypes[subtype];
if (supertype == 0) {
LOG.warn("eXist-db does not define a super-type for the sub-type {}", getTypeName(subtype), new Throwable());
Expand Down

0 comments on commit e2fba83

Please sign in to comment.