--- a/src/java.desktop/unix/native/libfontmanager/X11FontScaler.c Thu Oct 04 15:03:48 2018 +0530
+++ b/src/java.desktop/unix/native/libfontmanager/X11FontScaler.c Thu Oct 04 11:07:30 2018 -0700
@@ -66,6 +66,9 @@
NativeScalerContext *context =
(NativeScalerContext*)malloc(sizeof(NativeScalerContext));
+ if (context == NULL) {
+ return (jlong)(uintptr_t)0L;
+ }
context->xFont = NULL;
context->minGlyph = 0;
context->maxGlyph = 0;
@@ -92,6 +95,10 @@
(*env)->GetByteArrayRegion(env, xlfdBytes, 0, len, (jbyte*)xlfd);
xlfd[len] = '\0';
context = (NativeScalerContext*)malloc(sizeof(NativeScalerContext));
+ if (context == NULL) {
+ free(xlfd);
+ return (jlong)(uintptr_t)0L;
+ }
AWTLoadFont (xlfd, &(context->xFont));
free(xlfd);
@@ -232,10 +239,15 @@
Java_sun_font_NativeFont_getGlyphAdvance
(JNIEnv *env, jobject font2D, jlong pScalerContext, jint glyphCode) {
- NativeScalerContext *context = (NativeScalerContext*)pScalerContext;
- AWTFont xFont = (AWTFont)context->xFont;
AWTChar xcs = NULL;
jfloat advance = 0.0f;
+ AWTFont xFont;
+ NativeScalerContext *context = (NativeScalerContext*)pScalerContext;
+ if (context == NULL) {
+ return advance;
+ } else {
+ xFont = (AWTFont)context->xFont;
+ }
if (xFont == NULL || context->ptSize == NO_POINTSIZE) {
return advance;
@@ -271,9 +283,14 @@
Java_sun_font_NativeFont_getGlyphImageNoDefault
(JNIEnv *env, jobject font2D, jlong pScalerContext, jint glyphCode) {
+ AWTChar2b xChar;
+ AWTFont xFont;
NativeScalerContext *context = (NativeScalerContext*)pScalerContext;
- AWTFont xFont = context->xFont;
- AWTChar2b xChar;
+ if (context == NULL) {
+ return (jlong)0;
+ } else {
+ xFont = (AWTFont)context->xFont;
+ }
if (xFont == NULL || context->ptSize == NO_POINTSIZE) {
return (jlong)0;
@@ -292,9 +309,14 @@
Java_sun_font_NativeFont_getGlyphImage
(JNIEnv *env, jobject font2D, jlong pScalerContext, jint glyphCode) {
+ AWTChar2b xChar;
+ AWTFont xFont;
NativeScalerContext *context = (NativeScalerContext*)pScalerContext;
- AWTFont xFont = context->xFont;
- AWTChar2b xChar;
+ if (context == NULL) {
+ return (jlong)0;
+ } else {
+ xFont = (AWTFont)context->xFont;
+ }
if (xFont == NULL || context->ptSize == NO_POINTSIZE) {
return (jlong)0;
@@ -313,10 +335,15 @@
Java_sun_font_NativeFont_getFontMetrics
(JNIEnv *env, jobject font2D, jlong pScalerContext) {
- NativeScalerContext *context = (NativeScalerContext*)pScalerContext;
- AWTFont xFont = (AWTFont)context->xFont;
jfloat j0=0, j1=1, ay=j0, dy=j0, mx=j0;
jobject metrics;
+ AWTFont xFont;
+ NativeScalerContext *context = (NativeScalerContext*)pScalerContext;
+ if (context == NULL) {
+ return NULL;
+ } else {
+ xFont = (AWTFont)context->xFont;
+ }
if (xFont == NULL) {
return NULL;