8149120: TIFFField constructor throws ArrayIndexOutOfBoundsException and IllegalArgumentException for scenarios explained in description
Clean up parameter checking in TIFFField. Reviewed-by: prr
This commit is contained in:
parent
b1ccba1fcb
commit
a99085b4db
@ -519,6 +519,11 @@ public class TIFFField implements Cloneable {
|
|||||||
* @throws IllegalArgumentException if <code>type</code> is an unacceptable
|
* @throws IllegalArgumentException if <code>type</code> is an unacceptable
|
||||||
* data type for the supplied <code>TIFFTag</code>.
|
* data type for the supplied <code>TIFFTag</code>.
|
||||||
* @throws IllegalArgumentException if <code>count < 0</code>.
|
* @throws IllegalArgumentException if <code>count < 0</code>.
|
||||||
|
* @throws IllegalArgumentException if <code>count < 1</code>
|
||||||
|
* and <code>type</code> is <code>TIFF_RATIONAL</code> or
|
||||||
|
* <code>TIFF_SRATIONAL</code>.
|
||||||
|
* @throws IllegalArgumentException if <code>count ≠ 1</code>
|
||||||
|
* and <code>type</code> is <code>TIFF_IFD_POINTER</code>.
|
||||||
* @throws NullPointerException if <code>data == null</code>.
|
* @throws NullPointerException if <code>data == null</code>.
|
||||||
* @throws IllegalArgumentException if <code>data</code> is an instance of
|
* @throws IllegalArgumentException if <code>data</code> is an instance of
|
||||||
* a class incompatible with the specified type.
|
* a class incompatible with the specified type.
|
||||||
@ -534,6 +539,14 @@ public class TIFFField implements Cloneable {
|
|||||||
+ " for " + tag.getName() + " tag");
|
+ " for " + tag.getName() + " tag");
|
||||||
} else if(count < 0) {
|
} else if(count < 0) {
|
||||||
throw new IllegalArgumentException("count < 0!");
|
throw new IllegalArgumentException("count < 0!");
|
||||||
|
} else if((type == TIFFTag.TIFF_RATIONAL
|
||||||
|
|| type == TIFFTag.TIFF_SRATIONAL)
|
||||||
|
&& count < 1) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count < 1");
|
||||||
|
} else if (type == TIFFTag.TIFF_IFD_POINTER && count != 1) {
|
||||||
|
throw new IllegalArgumentException
|
||||||
|
("Type is TIFF_IFD_POINTER count != 1");
|
||||||
} else if(data == null) {
|
} else if(data == null) {
|
||||||
throw new NullPointerException("data == null!");
|
throw new NullPointerException("data == null!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user