From a67f8880ff26abb3796b9ed3aa0ad653c3fee112 Mon Sep 17 00:00:00 2001 From: ertauren <40769329+ertauren@users.noreply.github.com> Date: Wed, 24 Apr 2019 13:47:21 +0300 Subject: [PATCH] Always causes ArrayIndexOutOfBoundsException https://github.com/java-native-access/jna/blob/db28278447a82bf7dd4e2fe8e73df80398c92235/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java#L675 at this line, spesifiying Array's length as 0 does cause ArrayIndexOutOfBoundsException. Either need to alter Structure.java's toArray method or some change in here. I am bit new in java and github so there might be better solution than writing "((SYSTEM_LOGICAL_PROCESSOR_INFORMATION[])firstInformation).length" instead of "0". If there is better solution please consider this propose of file change as bug report. --- .../platform/src/com/sun/jna/platform/win32/Kernel32Util.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java b/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java index 1e18af7ab8..fdadf51751 100644 --- a/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java +++ b/contrib/platform/src/com/sun/jna/platform/win32/Kernel32Util.java @@ -672,7 +672,7 @@ public static final WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] getLogicalProce WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION firstInformation = new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION( memory); return (WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[]) firstInformation - .toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[0]); + .toArray(new WinNT.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[((SYSTEM_LOGICAL_PROCESSOR_INFORMATION[])firstInformation).length]); } /**