]> granicus.if.org Git - postgis/commitdiff
lwgeom_release (#699) move free if copy calls to end of functions in any place where...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 8 Feb 2012 17:19:53 +0000 (17:19 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 8 Feb 2012 17:19:53 +0000 (17:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9100 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_functions_basic.c
postgis/lwgeom_geos.c
postgis/lwgeom_sqlmm.c

index 14cef5da4f88ba8f4f0dc68f2626c090cf33e4c2..4883cb7d63d1cb16c29669ca4da9eb687304dd7f 100644 (file)
@@ -2204,11 +2204,11 @@ Datum LWGEOM_removepoint(PG_FUNCTION_ARGS)
        outline = lwline_removepoint(line, which);
        /* Release memory */
        lwline_free(line);
-       PG_FREE_IF_COPY(pglwg1, 0);
 
        result = geometry_serialize((LWGEOM *)outline);
        lwline_free(outline);
 
+       PG_FREE_IF_COPY(pglwg1, 0);
        PG_RETURN_POINTER(result);
 }
 
index 5f4e370b26b66f572f0d9c3dea04763d178bef54..031f2b4469f52eab2ec0648422176a93ada9ff35 100644 (file)
@@ -3397,15 +3397,16 @@ Datum ST_BuildArea(PG_FUNCTION_ARGS)
 
        lwgeom_out = lwgeom_buildarea(lwgeom_in);
        lwgeom_free(lwgeom_in) ;
-       PG_FREE_IF_COPY(geom, 0);
        
        if ( ! lwgeom_out ) {
+               PG_FREE_IF_COPY(geom, 0);
                PG_RETURN_NULL();
        }
 
        result = geometry_serialize(lwgeom_out) ;
        lwgeom_free(lwgeom_out) ;
 
+       PG_FREE_IF_COPY(geom, 0);
        PG_RETURN_POINTER(result);
 }
 
@@ -3493,17 +3494,18 @@ Datum ST_Split(PG_FUNCTION_ARGS)
        lwgeom_out = lwgeom_split(lwgeom_in, lwblade_in);
        lwgeom_free(lwgeom_in);
        lwgeom_free(lwblade_in);
-       PG_FREE_IF_COPY(blade_in, 1);
        
        if ( ! lwgeom_out )
        {
                PG_FREE_IF_COPY(in, 0); /* possibly referenced by lwgeom_out */
+               PG_FREE_IF_COPY(blade_in, 1);
                PG_RETURN_NULL();
        }
 
        out = geometry_serialize(lwgeom_out);
        lwgeom_free(lwgeom_out);
        PG_FREE_IF_COPY(in, 0); /* possibly referenced by lwgeom_out */
+       PG_FREE_IF_COPY(blade_in, 1);
 
        PG_RETURN_POINTER(out);
 }
@@ -3546,17 +3548,19 @@ Datum ST_SharedPaths(PG_FUNCTION_ARGS)
        lwgeom_out = lwgeom_sharedpaths(g1, g2);
        lwgeom_free(g1);
        lwgeom_free(g2);
-       PG_FREE_IF_COPY(geom1, 0);
-       PG_FREE_IF_COPY(geom2, 1);
 
        if ( ! lwgeom_out )
        {
+               PG_FREE_IF_COPY(geom1, 0);
+               PG_FREE_IF_COPY(geom2, 1);
                PG_RETURN_NULL();
        }
 
        out = geometry_serialize(lwgeom_out);
        lwgeom_free(lwgeom_out);
 
+       PG_FREE_IF_COPY(geom1, 0);
+       PG_FREE_IF_COPY(geom2, 1);
        PG_RETURN_POINTER(out);
 
 #endif /* POSTGIS_GEOS_VERSION >= 33 */
@@ -3592,16 +3596,17 @@ Datum ST_Node(PG_FUNCTION_ARGS)
 
        lwgeom_out = lwgeom_node(g1);
        lwgeom_free(g1);
-       PG_FREE_IF_COPY(geom1, 0);
 
        if ( ! lwgeom_out )
        {
+               PG_FREE_IF_COPY(geom1, 0);
                PG_RETURN_NULL();
        }
 
        out = geometry_serialize(lwgeom_out);
        lwgeom_free(lwgeom_out);
 
+       PG_FREE_IF_COPY(geom1, 0);
        PG_RETURN_POINTER(out);
 
 #endif /* POSTGIS_GEOS_VERSION >= 33 */
index 37d2d57b32330ef48fa4eee54051a66f5d8f53af..c3da5c64ee189b0f7a06feda3e3ee5ce032abf1d 100644 (file)
@@ -96,13 +96,16 @@ Datum LWGEOM_line_desegmentize(PG_FUNCTION_ARGS)
        igeom = lwgeom_from_gserialized(geom);
        ogeom = lwgeom_desegmentize(igeom);
        lwgeom_free(igeom);
-       PG_FREE_IF_COPY(geom, 0);
 
        if (ogeom == NULL)
+       {
+               PG_FREE_IF_COPY(geom, 0);
                PG_RETURN_NULL();
+       }
 
        ret = geometry_serialize(ogeom);
        lwgeom_free(ogeom);
+       PG_FREE_IF_COPY(geom, 0);
        PG_RETURN_POINTER(ret);
 }