changeset 7441:1ea9feb6d8c5

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
author jgodinez
date Fri, 08 Feb 2013 11:36:18 -0800
parents ad49012d10a1
children 5f0217537435
files src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c	Fri Feb 08 11:25:42 2013 -0800
+++ b/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;