]> source.dussan.org Git - poi.git/commitdiff
add additional sanity checks
authorSergey Vladimirov <sergey@apache.org>
Tue, 5 Jul 2011 03:02:12 +0000 (03:02 +0000)
committerSergey Vladimirov <sergey@apache.org>
Tue, 5 Jul 2011 03:02:12 +0000 (03:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142880 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/model/BytePropertyNode.java
src/scratchpad/src/org/apache/poi/hwpf/model/PropertyNode.java

index 4ceb2d1d8dbe0b2c50c33df5074115357bae0b60..59ac18e7b1d5a3c804425a5d3d7196a360a7718d 100644 (file)
@@ -38,6 +38,11 @@ public abstract class BytePropertyNode extends PropertyNode {
                                translator.getCharIndex(fcEnd, translator.getCharIndex(fcStart)),
                                buf
                );
+
+        if ( fcStart > fcEnd )
+            throw new IllegalArgumentException( "fcStart (" + fcStart
+                    + ") > fcEnd (" + fcEnd + ")" );
+
                 this.startBytes = fcStart;
                 this.endBytes = fcEnd;
        }
index e3338fd610a610067cf332decf077cb9801901ed..6c5a23972a43135d7c75667908eeee20e447bc45 100644 (file)
@@ -56,6 +56,10 @@ public abstract class PropertyNode implements Comparable, Cloneable
          _logger.log(POILogger.WARN, "A property claimed to start before zero, at " + _cpStart + "! Resetting it to zero, and hoping for the best");
          _cpStart = 0;
       }
+
+      if ( fcStart > fcEnd )
+          throw new IllegalArgumentException( "fcStart (" + fcStart
+                  + ") > fcEnd (" + fcEnd + ")" );
   }
 
   /**