8234323: NULL-check return value of SurfaceData_InitOps on macosx

Reviewed-by: clanger
This commit is contained in:
Matthias Baesken 2019-11-19 09:56:43 +01:00
parent 8aafb0e12c
commit 227d57e548
2 changed files with 10 additions and 0 deletions

View File

@ -1768,6 +1768,10 @@ JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_initRaster(JNIEnv
PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
ImageSDOps* isdo = (ImageSDOps*)SurfaceData_InitOps(env, bisd, sizeof(ImageSDOps));
if (isdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);

View File

@ -25,6 +25,7 @@
#import "PrinterSurfaceData.h"
#import "jni_util.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
@ -87,6 +88,11 @@ JNF_COCOA_ENTER(env);
PRINT("Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps")
PrintSDOps *psdo = (PrintSDOps*)SurfaceData_InitOps(env, jthis, sizeof(PrintSDOps));
if (psdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
psdo->nsRef = (NSGraphicsContext*)jlong_to_ptr(nsRef);
psdo->width = width;
psdo->height = height;