8232381: add result NULL-checking to freetypeScaler.c
authormbaesken
Fri, 18 Oct 2019 14:56:01 +0200
changeset 58685 4b13a908c2d0
parent 58684 2e0462f4cf4e
child 58686 0279391875bf
8232381: add result NULL-checking to freetypeScaler.c Reviewed-by: clanger, prr
src/java.desktop/share/native/libfontmanager/freetypeScaler.c
--- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c	Fri Oct 18 14:15:10 2019 +0800
+++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c	Fri Oct 18 14:56:01 2019 +0200
@@ -673,10 +673,14 @@
                                  pScalerContext, pScaler, glyphCode);
      info = (GlyphInfo*) jlong_to_ptr(image);
 
-     (*env)->SetFloatField(env, metrics, sunFontIDs.xFID, info->advanceX);
-     (*env)->SetFloatField(env, metrics, sunFontIDs.yFID, info->advanceY);
-
-     free(info);
+     if (info != NULL) {
+         (*env)->SetFloatField(env, metrics, sunFontIDs.xFID, info->advanceX);
+         (*env)->SetFloatField(env, metrics, sunFontIDs.yFID, info->advanceY);
+         free(info);
+     } else {
+         (*env)->SetFloatField(env, metrics, sunFontIDs.xFID, 0.0f);
+         (*env)->SetFloatField(env, metrics, sunFontIDs.yFID, 0.0f);
+     }
 }