diff options
4 files changed, 4 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java index 79e32004c5..85ede2127b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java @@ -743,10 +743,10 @@ public String getText () { */ public String getText (int start, int end) { checkWidget (); + if (start > end) return ""; int length = OS.TXNDataSize (txnObject) / 2; start = Math.max (0, start); end = Math.min (end, length - 1); - if (start > end) return ""; return getTXNText (start, end + 1); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index b7a66ce28a..204645a2ed 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -741,6 +741,7 @@ public String getText () { */ public String getText (int start, int end) { checkWidget (); + if (start > end) return ""; if (!(0 <= start && start <= end)) error (SWT.ERROR_INVALID_RANGE); int address; if ((style & SWT.SINGLE) != 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java index cc7953dd3a..1c7abf2a32 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java @@ -775,11 +775,11 @@ public String getText () { */ public String getText (int start, int end) { checkWidget(); + if (start > end) return ""; boolean hasEcho = echoCharacter != '\0'; int length = hasEcho ? hiddenText.length () : OS.XmTextGetLastPosition (handle); start = Math.max (0, start); end = Math.min (end, length - 1); - if (start > end) return ""; if (hasEcho) return hiddenText.substring (start, end + 1); int numChars = end - start + 1; int bufLength = numChars * OS.MB_CUR_MAX () + 1; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java index 1baa00fb49..2c1aac5a6a 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java @@ -724,11 +724,11 @@ int getTabWidth (int tabs) { */ public String getText (int start, int end) { checkWidget (); + if (start > end) return ""; String text = getText (); int length = text.length (); start = Math.max (0, start); end = Math.min (end, length - 1); - if (start > end) return ""; /* * NOTE: The current implementation uses substring () * which can reference a potentially large character |