Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2021-11-12 22:04:19 +0000
committerNiraj Modi2021-11-30 11:06:17 +0000
commit15e5660efaf716f25c22dff4fd09f83b59781b0a (patch)
treedf24bc921d55ba6f8c3b4c78b7af572158b988b2
parent17b4024759c8084afa680a06b7b2803463e84114 (diff)
downloadeclipse.platform.swt-15e5660efaf716f25c22dff4fd09f83b59781b0a.tar.gz
eclipse.platform.swt-15e5660efaf716f25c22dff4fd09f83b59781b0a.tar.xz
eclipse.platform.swt-15e5660efaf716f25c22dff4fd09f83b59781b0a.zip
Bug 577240: Allocate a bigger buffer to match win32 API docs
Change-Id: I4b96e6d7a35b33b6b22fc2ee942c0d3f4c40cafd Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187699 Tested-by: Niraj Modi <niraj.modi@in.ibm.com> Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
index 2a13c542e1..676214df23 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java
@@ -2721,7 +2721,11 @@ StyleItem[] itemize () {
OS.ScriptApplyDigitSubstitution(0, scriptControl, scriptState);
long hHeap = OS.GetProcessHeap();
- long pItems = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, MAX_ITEM * SCRIPT_ITEM.sizeof);
+ // This buffer needs to be one entry bigger than the cMaxItems param to ScriptItemize
+ // see https://docs.microsoft.com/en-us/windows/win32/api/usp10/nf-usp10-scriptitemize
+ // and https://bugzilla.mozilla.org/show_bug.cgi?id=366643 which was a similar bug
+ // in Mozilla. The MSDN docs have been updated since the Mozilla bug to make this clear
+ long pItems = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, (1 + MAX_ITEM) * SCRIPT_ITEM.sizeof);
if (pItems == 0) SWT.error(SWT.ERROR_NO_HANDLES);
int[] pcItems = new int[1];
char[] chars = new char[length];

Back to the top