8005261: [parfait] #415 sun/java2d/opengl/GLXSurfaceData.c Memory leak of pointer 'glxsdo' allocated with malloc
authorjgodinez
Fri, 08 Feb 2013 11:36:18 -0800
changeset 15629 a041f5885d90
parent 15628 228422512f97
child 15630 f644cf0bda45
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
jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
--- 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;