From 37f89e6be67dccd11409cafd1bac0d715c1e5651 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Mon, 12 Jul 2010 13:16:28 -0700 Subject: [PATCH] 6959998: Return of SurfaceData_InitOps point not checked in all cases (parfait found these) Reviewed-by: prr --- jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c | 4 ++++ jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c | 5 +++++ jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c | 4 ++++ jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c | 4 ++++ .../native/sun/java2d/windows/GDIWindowSurfaceData.cpp | 4 ++++ 5 files changed, 21 insertions(+) diff --git a/jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c b/jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c index d9f1950c443..d2b3b33a02f 100644 --- a/jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c +++ b/jdk/src/share/native/sun/awt/image/BufImgSurfaceData.c @@ -111,6 +111,10 @@ Java_sun_awt_image_BufImgSurfaceData_initRaster(JNIEnv *env, jobject bisd, { BufImgSDOps *bisdo = (BufImgSDOps*)SurfaceData_InitOps(env, bisd, sizeof(BufImgSDOps)); + if (bisdo == NULL) { + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } bisdo->sdOps.Lock = BufImg_Lock; bisdo->sdOps.GetRasInfo = BufImg_GetRasInfo; bisdo->sdOps.Release = BufImg_Release; diff --git a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c index 618f7943415..3c20b825b56 100644 --- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c +++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c @@ -65,6 +65,11 @@ Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd, J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps"); + if (oglsdo == NULL) { + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } + if (glxsdo == NULL) { JNU_ThrowOutOfMemoryError(env, "creating native GLX ops"); return; diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index dcd2fba19c5..ab51bd259c4 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -253,6 +253,10 @@ Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd, { #ifndef HEADLESS X11SDOps *xsdo = (X11SDOps*)SurfaceData_InitOps(env, xsd, sizeof(X11SDOps)); + if (xsdo == NULL) { + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } xsdo->sdOps.Lock = X11SD_Lock; xsdo->sdOps.GetRasInfo = X11SD_GetRasInfo; xsdo->sdOps.Unlock = X11SD_Unlock; diff --git a/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c b/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c index cac8c0237b7..03d81a3924b 100644 --- a/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c +++ b/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c @@ -66,6 +66,10 @@ Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd, J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps"); + if (oglsdo == NULL) { + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } if (wglsdo == NULL) { JNU_ThrowOutOfMemoryError(env, "creating native wgl ops"); return; diff --git a/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp b/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp index c902dfc24d2..21b944d2084 100644 --- a/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp +++ b/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp @@ -363,6 +363,10 @@ Java_sun_java2d_windows_GDIWindowSurfaceData_initOps(JNIEnv *env, jobject wsd, { J2dTraceLn(J2D_TRACE_INFO, "GDIWindowSurfaceData_initOps"); GDIWinSDOps *wsdo = (GDIWinSDOps *)SurfaceData_InitOps(env, wsd, sizeof(GDIWinSDOps)); + if (wsdo == NULL) { + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } wsdo->sdOps.Lock = GDIWinSD_Lock; wsdo->sdOps.GetRasInfo = GDIWinSD_GetRasInfo; wsdo->sdOps.Unlock = GDIWinSD_Unlock;