Skip to content

Commit 4cf611f

Browse files
committed
Widget.getData: fix NPE
fix java.lang.NullPointerException: Cannot read the array length because "table" is null As Widget.setData(Object) can be called with null argument even if KEYED_DATA is set.
1 parent 478a69f commit 4cf611f

File tree

1 file changed

+1
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+1
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,7 @@ public Object getData () {
593593
public Object getData (String key) {
594594
checkWidget();
595595
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
596-
if ((state & KEYED_DATA) != 0) {
597-
Object [] table = (Object []) data;
596+
if ((state & KEYED_DATA) != 0 && data instanceof Object [] table) {
598597
for (int i=1; i<table.length; i+=2) {
599598
if (key.equals (table [i])) return table [i+1];
600599
}

0 commit comments

Comments
 (0)