Skip to content

Commit 227d57e

Browse files
committed
8234323: NULL-check return value of SurfaceData_InitOps on macosx
Reviewed-by: clanger
1 parent 8aafb0e commit 227d57e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,10 @@ JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_initRaster(JNIEnv
17681768
PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
17691769

17701770
ImageSDOps* isdo = (ImageSDOps*)SurfaceData_InitOps(env, bisd, sizeof(ImageSDOps));
1771+
if (isdo == NULL) {
1772+
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
1773+
return;
1774+
}
17711775

17721776
pthread_mutexattr_t attr;
17731777
pthread_mutexattr_init(&attr);

src/java.desktop/macosx/native/libawt_lwawt/awt/PrinterSurfaceData.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626

2727
#import "PrinterSurfaceData.h"
28+
#import "jni_util.h"
2829
#import <JavaNativeFoundation/JavaNativeFoundation.h>
2930

3031

@@ -87,6 +88,11 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps(JNIEnv
8788
PRINT("Java_sun_lwawt_macosx_CPrinterSurfaceData_initOps")
8889

8990
PrintSDOps *psdo = (PrintSDOps*)SurfaceData_InitOps(env, jthis, sizeof(PrintSDOps));
91+
if (psdo == NULL) {
92+
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
93+
return;
94+
}
95+
9096
psdo->nsRef = (NSGraphicsContext*)jlong_to_ptr(nsRef);
9197
psdo->width = width;
9298
psdo->height = height;

0 commit comments

Comments
 (0)