[postgis-tickets] r16361 - Avoid memory exhaustion when building a btree index (references #4004)
Paul Ramsey
pramsey at cleverelephant.ca
Fri Jan 26 04:47:38 PST 2018
Author: pramsey
Date: 2018-01-26 04:47:38 -0800 (Fri, 26 Jan 2018)
New Revision: 16361
Modified:
branches/2.4/NEWS
branches/2.4/postgis/geography_btree.c
Log:
Avoid memory exhaustion when building a btree index (references #4004)
>From Edmund Horner
Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS 2018-01-26 12:43:51 UTC (rev 16360)
+++ branches/2.4/NEWS 2018-01-26 12:47:38 UTC (rev 16361)
@@ -3,6 +3,7 @@
* Bug fixes *
- #3978, Fix KNN when upgrading from 2.1 or older (Sandro Santilli)
+ - #4004, Avoid memory exhaustion when building a btree index (Edmund Horner)
PostGIS 2.3.6
2018/01/17
Modified: branches/2.4/postgis/geography_btree.c
===================================================================
--- branches/2.4/postgis/geography_btree.c 2018-01-26 12:43:51 UTC (rev 16360)
+++ branches/2.4/postgis/geography_btree.c 2018-01-26 12:47:38 UTC (rev 16361)
@@ -51,6 +51,8 @@
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
@@ -67,6 +69,8 @@
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
@@ -83,6 +87,8 @@
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
@@ -99,6 +105,8 @@
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
@@ -115,6 +123,8 @@
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
@@ -130,5 +140,8 @@
{
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);
}
More information about the postgis-tickets
mailing list