diff options
Diffstat (limited to 'src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java index 78a18e269d..37ee631776 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePartName.java @@ -289,7 +289,8 @@ public final class PackagePartName implements Comparable<PackagePartName> { private static void checkPCharCompliance(String segment) throws InvalidFormatException { boolean errorFlag; - for (int i = 0; i < segment.length(); ++i) { + final int length = segment.length(); + for (int i = 0; i < length; ++i) { char c = segment.charAt(i); errorFlag = true; @@ -328,7 +329,7 @@ public final class PackagePartName implements Comparable<PackagePartName> { if (errorFlag && c == '%') { // We certainly found an encoded character, check for length // now ( '%' HEXDIGIT HEXDIGIT) - if (((segment.length() - i) < 2)) { + if (((length - i) < 2)) { throw new InvalidFormatException("The segment " + segment + " contain invalid encoded character !"); } |