aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Oldenburg2014-05-15 10:43:31 (EDT)
committerRoland Oldenburg2014-05-20 02:31:29 (EDT)
commit0fc715ad3225dc7b91ceef95969ce79b13bc7afe (patch)
treef6c241a339cbc8453e93af2982ec4eee46e27801
parent23a4ae5a01c03d1e89c88b45ce6a00f7b7cfc803 (diff)
downloadeclipse.platform.swt-0fc715ad3225dc7b91ceef95969ce79b13bc7afe.zip
eclipse.platform.swt-0fc715ad3225dc7b91ceef95969ce79b13bc7afe.tar.gz
eclipse.platform.swt-0fc715ad3225dc7b91ceef95969ce79b13bc7afe.tar.bz2
Bug 292199 - [Widgets] ArrayIndexOutOfBoundsException: 4 in SWT table inrefs/changes/11/26711/5
Java Browsing Perspective match "win32 item count" with "items.length" to prevent AIOOB Change-Id: If3ee01cba225d38c616b4b735f1c5381b1e658f5 Signed-off-by: Roland Oldenburg <r.oldenburg@hsp-software.de>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 4f53ab7..59d4323 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Roland Oldenburg <r.oldenburg@hsp-software.de> - Bug 292199
*******************************************************************************/
package org.eclipse.swt.widgets;
@@ -212,6 +213,19 @@ void _checkShrink () {
if (!ignoreShrink) {
/* Resize the item array to match the item count */
int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+
+ /*
+ * Bug in Windows. Call to OS.LVM_GETITEMCOUNT unexpectedly returns zero,
+ * leading to a possible "ArrayIndexOutOfBoundsException: 4" in SWT table.
+ * So, double check for any existing living items in the table and fixing
+ * the count value. Refer bug 292199.
+ */
+ if (count == 0 && items.length > 4) {
+ while (count<items.length && items[count] != null && !items[count].isDisposed()) {
+ count++;
+ }
+ }
+
if (items.length > 4 && items.length - count > 3) {
int length = Math.max (4, (count + 3) / 4 * 4);
TableItem [] newItems = new TableItem [length];
@@ -252,6 +266,7 @@ TableItem _getItem (int index, boolean create) {
TableItem _getItem (int index, boolean create, int count) {
//TODO - code could be shared but it would mix keyed and non-keyed logic
if (keys == null) {
+ if (index >= items.length) return null;
if ((style & SWT.VIRTUAL) == 0 || !create) return items [index];
if (items [index] != null) return items [index];
return items [index] = new TableItem (this, SWT.NONE, -1, false);