| Summary: | [win32] StringIndexOutOfBoundsException in Table.wmNotifyChild | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Thomas Singer <eclipse> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | niraj.modi |
| Version: | 4.7 | Keywords: | triaged |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
(In reply to Thomas Singer from comment #0) > I've got an automatic bug report from a user with following exception (using > SmartGit 17.0.4 which uses SWT version 4.723): > > java.lang.StringIndexOutOfBoundsException: String index out of range: -1 > at java.lang.String.getChars(String.java:824) > at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6946) > at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5848) > at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:2023) > at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5402) > at org.eclipse.swt.widgets.Control.windowProc(Control.java:4878) > at org.eclipse.swt.widgets.Display.windowProc(Display.java:5194) > at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) > at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2447) > at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:580) > at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:446) > at org.eclipse.swt.widgets.Control.windowProc(Control.java:4920) > at org.eclipse.swt.widgets.Table.windowProc(Table.java:6025) > at org.eclipse.swt.widgets.Display.windowProc(Display.java:5194) > at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method) > at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3145) > at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3815) > ... > > This means, the length variable in following code was -1: > IMHO, this can happen if plvfi.cchTextMax == 0. Yes, going by the code it very likely that if plvfi.cchTextMax is 0, then we will end-up with a negative length of -1 in below expression. int length = Math.min (string.length (), plvfi.cchTextMax - 1); Which will lead to SIOOBE at below line: >> string.getChars (0, length, buffer, 0); Need to add necessary checks to avoid negative length value, will share a gerrit shortly. (In reply to Niraj Modi from comment #2) > Need to add necessary checks to avoid negative length value, will share a > gerrit shortly. StringIndexOutOfBoundsException issue already there in the SWT-Inbox raised by the automatic error-reporting system via bug 500832. *** This bug has been marked as a duplicate of bug 500832 *** |
I've got an automatic bug report from a user with following exception (using SmartGit 17.0.4 which uses SWT version 4.723): java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.getChars(String.java:824) at org.eclipse.swt.widgets.Table.wmNotifyChild(Table.java:6946) at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5848) at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:2023) at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5402) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4878) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5194) at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method) at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2447) at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:580) at org.eclipse.swt.widgets.Table.callWindowProc(Table.java:446) at org.eclipse.swt.widgets.Control.windowProc(Control.java:4920) at org.eclipse.swt.widgets.Table.windowProc(Table.java:6025) at org.eclipse.swt.widgets.Display.windowProc(Display.java:5194) at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3145) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3815) ... This means, the length variable in following code was -1: ... char [] buffer = display.tableBuffer; if (buffer == null || plvfi.cchTextMax > buffer.length) { buffer = display.tableBuffer = new char [plvfi.cchTextMax]; } >> string.getChars (0, length, buffer, 0); if (tipRequested) { /* * Bug in Windows. The tooltip is only displayed up to * the first line delimiter. The fix is to remove all * line delimiter characters. */ ... IMHO, this can happen if plvfi.cchTextMax == 0.