]> granicus.if.org Git - postgis/commitdiff
Fix memory leaks in BTREE operators
authorSandro Santilli <strk@kbt.io>
Sun, 1 Oct 2017 18:31:56 +0000 (18:31 +0000)
committerSandro Santilli <strk@kbt.io>
Sun, 1 Oct 2017 18:31:56 +0000 (18:31 +0000)
References #3864 for 2.4 branch

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

NEWS
postgis/lwgeom_btree.c

diff --git a/NEWS b/NEWS
index e16afcd095c00c1573e4053168bb6de2280c0d0e..ebe05ae1f2bf85bee02df4f604d7253e99e0eec2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+PostGIS 2.4.1dev
+YYYY/MM/DD
+
+ * Bug fixes *
+  - #3864, Fix memory leaks in BTREE operators
+
 PostGIS 2.4.0
 2017/09/30
 
index c21defa901979c82e54a5f5358d3b5528e3dda73..cfca3be4a9dd4726f00e4cbdd3d336aa24386b91 100644 (file)
@@ -52,6 +52,8 @@ Datum lwgeom_lt(PG_FUNCTION_ARGS)
        GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
        GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
        int cmp = gserialized_cmp(g1, g2);
+       PG_FREE_IF_COPY(g1, 0);
+       PG_FREE_IF_COPY(g2, 1);
        if (cmp < 0)
                PG_RETURN_BOOL(TRUE);
        else
@@ -64,6 +66,8 @@ Datum lwgeom_le(PG_FUNCTION_ARGS)
        GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
        GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
        int cmp = gserialized_cmp(g1, g2);
+       PG_FREE_IF_COPY(g1, 0);
+       PG_FREE_IF_COPY(g2, 1);
        if (cmp == 0)
                PG_RETURN_BOOL(TRUE);
        else
@@ -76,6 +80,8 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS)
        GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
        GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
        int cmp = gserialized_cmp(g1, g2);
+       PG_FREE_IF_COPY(g1, 0);
+       PG_FREE_IF_COPY(g2, 1);
        if (cmp == 0)
                PG_RETURN_BOOL(TRUE);
        else
@@ -88,6 +94,8 @@ Datum lwgeom_ge(PG_FUNCTION_ARGS)
        GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
        GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
        int cmp = gserialized_cmp(g1, g2);
+       PG_FREE_IF_COPY(g1, 0);
+       PG_FREE_IF_COPY(g2, 1);
        if (cmp >= 0)
                PG_RETURN_BOOL(TRUE);
        else
@@ -100,6 +108,8 @@ Datum lwgeom_gt(PG_FUNCTION_ARGS)
        GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
        GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
        int cmp = gserialized_cmp(g1, g2);
+       PG_FREE_IF_COPY(g1, 0);
+       PG_FREE_IF_COPY(g2, 1);
        if (cmp > 0)
                PG_RETURN_BOOL(TRUE);
        else
@@ -111,6 +121,9 @@ Datum lwgeom_cmp(PG_FUNCTION_ARGS)
 {
        GSERIALIZED *g1 = PG_GETARG_GSERIALIZED_P(0);
        GSERIALIZED *g2 = PG_GETARG_GSERIALIZED_P(1);
-    PG_RETURN_INT32(gserialized_cmp(g1, g2));
+       int ret = gserialized_cmp(g1, g2);
+       PG_FREE_IF_COPY(g1, 0);
+       PG_FREE_IF_COPY(g2, 1);
+       PG_RETURN_INT32(ret);
 }