8005261: [parfait] #415 sun/java2d/opengl/GLXSurfaceData.c Memory leak of pointer 'glxsdo' allocated with malloc
Reviewed-by: prr, vadim
Contributed-by: jia-hong.chen@oracle.com
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Fri Feb 08 11:25:42 2013 -0800
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Fri Feb 08 11:36:18 2013 -0800
@@ -57,22 +57,23 @@
jobject peer, jlong aData)
{
#ifndef HEADLESS
- OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
- sizeof(OGLSDOps));
GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
- 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;
}
+ OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
+ sizeof(OGLSDOps));
+ if (oglsdo == NULL) {
+ free(glxsdo);
+ JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
+ return;
+ }
+
+ J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
+
oglsdo->privOps = glxsdo;
oglsdo->sdOps.Lock = OGLSD_Lock;