changeset 1634:551c49cb2e2a

2009-02-11 Omair Majid <omajid@redhat.com> * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java (write): Throw IllegalArgumentException instead of ArrayIndexOutOfBoundsException for length. * pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java (read): Fixed bounds checking.
author Omair Majid <omajid@redhat.com>
date Wed, 11 Feb 2009 11:49:45 -0500
parents 24c29e381e49
children 493d9814f1ae
files ChangeLog pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
diffstat 3 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Feb 11 09:14:17 2009 -0500
+++ b/ChangeLog	Wed Feb 11 11:49:45 2009 -0500
@@ -1,3 +1,11 @@
+2009-02-11  Omair Majid  <omajid@redhat.com>
+
+	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java
+	(write): Throw IllegalArgumentException instead of 
+	ArrayIndexOutOfBoundsException for length.
+	* pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java
+	(read): Fixed bounds checking.
+
 2009-02-11  Marc Schoenefeld <mschoene@redhat.com>
             Omair Majid  <omajid@redhat.com>
 
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Wed Feb 11 09:14:17 2009 -0500
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioSourceDataLine.java	Wed Feb 11 11:49:45 2009 -0500
@@ -151,6 +151,11 @@
 			throw new IllegalArgumentException(
 					"amount of data to write does not represent an integral number of frames");
 		}
+		
+		if (length < 0) {
+		    throw new IllegalArgumentException("length is negative");
+		}
+		
 		if (length < 0 || offset < 0 || offset > data.length - length) {
 			throw new ArrayIndexOutOfBoundsException(
 					"Overflow condition: buffer.length=" + data.length + 
--- a/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java	Wed Feb 11 09:14:17 2009 -0500
+++ b/pulseaudio/src/java/org/classpath/icedtea/pulseaudio/PulseAudioTargetDataLine.java	Wed Feb 11 11:49:45 2009 -0500
@@ -156,10 +156,10 @@
 		if (length < 0) {
 			throw new IllegalArgumentException("length is negative");
 		}
-
-		if (length + offset > data.length) {
-			throw new ArrayIndexOutOfBoundsException("index: "
-					+ (length + offset) + " array size: " + data.length);
+		
+		if ( offset < 0 || offset > data.length - length) {
+			throw new ArrayIndexOutOfBoundsException("array size: " + data.length
+					+ " offset:" + offset + " length:" + length );
 		}
 
 		/* everything ok */