https://bugs.openjdk.java.net/browse/JDK-8160695

A simple fix to ensure we check an array index is positive.
In fact the value is always positive anyway, so this is just for "extra" safety.

diff --git a/src/java.desktop/share/native/libfontmanager/scriptMapping.c b/src/java.desktop/share/native/libfontmanager/scriptMapping.c
--- a/src/java.desktop/share/native/libfontmanager/scriptMapping.c
+++ b/src/java.desktop/share/native/libfontmanager/scriptMapping.c
@@ -85,7 +85,7 @@
 int MAX_ICU_SCRIPTCODE = 45;

 hb_script_t getHBScriptCode(int code) {
-    if (code > MAX_ICU_SCRIPTCODE) {
+    if ((code < 0) || (code > MAX_ICU_SCRIPTCODE)) {
         return HB_SCRIPT_INVALID;
     }
     return ICU_to_Harfbuzz_ScriptCode[code];


-phil.

Reply via email to