]> granicus.if.org Git - postgis/commitdiff
Always return a fully owned object to lwgeom/geos function callers
authorSandro Santilli <strk@keybit.net>
Wed, 19 Aug 2015 16:41:01 +0000 (16:41 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 19 Aug 2015 16:41:01 +0000 (16:41 +0000)
See #3245

git-svn-id: http://svn.osgeo.org/postgis/trunk@13942 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgeom_geos.c
liblwgeom/lwgeom_geos_split.c

index dc6052c42e9f29e936c15b736557a50965cb05c1..a6f0c16e01732589d35af6292292f6665b536a69 100644 (file)
@@ -545,11 +545,11 @@ lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
 
        /* A.Intersection(Empty) == Empty */
        if ( lwgeom_is_empty(geom2) )
-               return lwgeom_clone(geom2);
+               return lwgeom_clone_deep(geom2);
 
        /* Empty.Intersection(A) == Empty */
        if ( lwgeom_is_empty(geom1) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
        /* ensure srids are identical */
        srid = (int)(geom1->srid);
@@ -689,7 +689,7 @@ lwgeom_unaryunion(const LWGEOM *geom1)
 
        /* Empty.UnaryUnion() == Empty */
        if ( lwgeom_is_empty(geom1) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
        initGEOS(lwnotice, lwgeom_geos_error);
 
@@ -741,11 +741,11 @@ lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2)
 
        /* A.Difference(Empty) == A */
        if ( lwgeom_is_empty(geom2) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
        /* Empty.Intersection(A) == Empty */
        if ( lwgeom_is_empty(geom1) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
        /* ensure srids are identical */
        srid = (int)(geom1->srid);
@@ -815,11 +815,11 @@ lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2)
 
        /* A.SymDifference(Empty) == A */
        if ( lwgeom_is_empty(geom2) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
        /* Empty.DymDifference(B) == B */
        if ( lwgeom_is_empty(geom1) )
-               return lwgeom_clone(geom2);
+               return lwgeom_clone_deep(geom2);
 
        /* ensure srids are identical */
        srid = (int)(geom1->srid);
@@ -890,11 +890,11 @@ lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
 
        /* A.Union(empty) == A */
        if ( lwgeom_is_empty(geom1) )
-               return lwgeom_clone(geom2);
+               return lwgeom_clone_deep(geom2);
 
        /* B.Union(empty) == B */
        if ( lwgeom_is_empty(geom2) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
 
        /* ensure srids are identical */
@@ -971,7 +971,7 @@ lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double
 
        /* A.Intersection(Empty) == Empty */
        if ( lwgeom_is_empty(geom1) )
-               return lwgeom_clone(geom1);
+               return lwgeom_clone_deep(geom1);
 
        is3d = FLAGS_GET_Z(geom1->flags);
 
index 6b3886ad382cd2b3dbe6707b14147c5dc0f78d64..25173404cbef0d76dbe4350cc0d7141fa4c45cd9 100644 (file)
@@ -170,7 +170,7 @@ lwline_split_by_point(const LWLINE* lwline_in, const LWPOINT* blade_in)
                FLAGS_GET_M(lwline_in->flags));
        if ( lwline_split_by_point_to(lwline_in, blade_in, out) < 2 )
        {
-               lwmline_add_lwline(out, lwline_clone(lwline_in));
+               lwmline_add_lwline(out, lwline_clone_deep(lwline_in));
        }
 
        /* Turn multiline into collection */
@@ -188,7 +188,7 @@ lwline_split_by_mpoint(const LWLINE* lwline_in, const LWMPOINT* mp)
   out = lwmline_construct_empty(lwline_in->srid,
           FLAGS_GET_Z(lwline_in->flags),
           FLAGS_GET_M(lwline_in->flags));
-  lwmline_add_lwline(out, lwline_clone(lwline_in));
+  lwmline_add_lwline(out, lwline_clone_deep(lwline_in));
 
   for (i=0; i<mp->ngeoms; ++i)
   {