aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2008-08-13 16:20:00 +0000
committerKevin Rushforth <[email protected]>2008-08-13 16:20:00 +0000
commit53820abc564ad5bad897d4d77a944f904900bc9d (patch)
tree428eb9348fee578253d07c48a56727813e888c19 /src/classes
parent329cd90c8b0d6533c15b8d5ef4d2e5ea531cc616 (diff)
Fixed 591: ArrayIndexOutOfBoundsException in NnuIdManager
git-svn-id: https://svn.java.net/svn/j3d-core~svn/branches/dev-1_6@930 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/share/javax/media/j3d/NnuIdManager.java56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/classes/share/javax/media/j3d/NnuIdManager.java b/src/classes/share/javax/media/j3d/NnuIdManager.java
index 78cfac3..bf0d43a 100644
--- a/src/classes/share/javax/media/j3d/NnuIdManager.java
+++ b/src/classes/share/javax/media/j3d/NnuIdManager.java
@@ -218,29 +218,38 @@ class NnuIdManager {
if(size > 0) {
NnuId newNnuIdArr[] = new NnuId[size];
- for(i=0; i<nnuIdArr1.length; i++) {
- index = equals(nnuIdArr0, nnuIdArr1[i], 0, nnuIdArr0.length);
-
- if(index >= 0) {
- found = true;
- if(index == curStart) {
- curStart++;
- }
- else {
- len = index - curStart;
- System.arraycopy(nnuIdArr0, curStart,
- newNnuIdArr, newStart, len);
-
- curStart = index+1;
- newStart = newStart + len;
- }
- }
- else {
- found = false;
- MasterControl.getCoreLogger().severe("Can't Find matching nnuId.");
- }
- }
-
+ for (i = 0; i < nnuIdArr1.length; i++) {
+ index = equals(nnuIdArr0, nnuIdArr1[i], 0, nnuIdArr0.length);
+
+ if (index >= 0) {
+ found = true;
+ if ((i < (nnuIdArr1.length - 1)) && nnuIdArr1[i].getId() == nnuIdArr1[i + 1].getId()) {
+ // Remove element from original array
+ NnuId[] tmpNnuIdArr0 = new NnuId[nnuIdArr0.length - 1];
+ System.arraycopy(nnuIdArr0, 0, tmpNnuIdArr0, 0, index);
+ System.arraycopy(nnuIdArr0, index + 1,
+ tmpNnuIdArr0, index, nnuIdArr0.length - index - 1);
+ nnuIdArr0 = tmpNnuIdArr0;
+ } else {
+ // Copy elements from original array to new array up to
+ // but not including the element we are removing
+ if (index == curStart) {
+ curStart++;
+ } else {
+ len = index - curStart;
+ System.arraycopy(nnuIdArr0, curStart,
+ newNnuIdArr, newStart, len);
+
+ curStart = index + 1;
+ newStart = newStart + len;
+ }
+ }
+ } else {
+ found = false;
+ MasterControl.getCoreLogger().severe("Can't Find matching nnuId.");
+ }
+ }
+
if((found == true) && (curStart < nnuIdArr0.length)) {
len = nnuIdArr0.length - curStart;
System.arraycopy(nnuIdArr0, curStart, newNnuIdArr, newStart, len);
@@ -253,6 +262,7 @@ class NnuIdManager {
}
else {
// We are in trouble !!!
+ MasterControl.getCoreLogger().severe("Attempt to remove more elements than are present");
}
return null;