Commit 7c780482 authored by Paul Ramsey's avatar Paul Ramsey

Avoid memory exhaustion when building a btree index (references #4004)

From Edmund Horner git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@16361 b70326c6-7e19-0410-871a-916f4a2858ee
parent 400ad278
Pipeline #16668130 passed with stage
in 15 minutes 27 seconds
......@@ -3,6 +3,7 @@ PostGIS 2.4.4dev
* 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
......
......@@ -51,6 +51,8 @@ Datum geography_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
......@@ -67,6 +69,8 @@ Datum geography_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
......@@ -83,6 +87,8 @@ Datum geography_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
......@@ -99,6 +105,8 @@ Datum geography_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
......@@ -115,6 +123,8 @@ Datum geography_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
......@@ -130,5 +140,8 @@ Datum geography_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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment