fix possible memory leak in bezierPatchMeshMake
authorDaniel Zimmermann <netzimme@aol.com>
Wed, 26 Nov 2008 10:48:53 +0000 (11:48 +0100)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 26 Nov 2008 14:20:02 +0000 (07:20 -0700)
src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc

index 3dc1631..ac7ff84 100644 (file)
@@ -103,23 +103,22 @@ bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int us
   int dimension;
   int the_ustride;
   int the_vstride;
-  
-  bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
-  assert(ret);
 
-  ret->bpatch = NULL;
-  ret->bpatch_normal = NULL;
-  ret->bpatch_color  = NULL;
-  ret->bpatch_texcoord = NULL;
   if(maptype == GL_MAP2_VERTEX_3) dimension = 3;
   else if (maptype==GL_MAP2_VERTEX_4) dimension = 4;
   else {
     fprintf(stderr, "error in inMap2f, maptype=%i is wrong, maptype,map is invalid\n", maptype);
     return NULL;
   }
-  
+
+  bezierPatchMesh *ret = (bezierPatchMesh*) malloc(sizeof(bezierPatchMesh));
+  assert(ret);
+
+  ret->bpatch_normal = NULL;
+  ret->bpatch_color  = NULL;
+  ret->bpatch_texcoord = NULL;
   ret->bpatch = bezierPatchMake(umin, vmin, umax, vmax, uorder, vorder, dimension);
+
   /*copy the control points there*/
   the_ustride = vorder * dimension;
   the_vstride = dimension;