diff --git a/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c b/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c index ee553224b25..ffcb95b0af5 100644 --- a/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c +++ b/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c @@ -67,14 +67,15 @@ 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; } + if (oglsdo == NULL) { + free(wglsdo); + JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed."); + return; + } oglsdo->privOps = wglsdo;