summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2008-04-11 22:53:24 +0000
committerTom Lane2008-04-11 22:53:24 +0000
commit4c3f3716cc736f5e513784292d467c6a222d9c7b (patch)
tree279897e72d1522a183bf7982dff3ec5f5c893c06
parentdf52ecc3145a2feb241801484512aff3f0effbc7 (diff)
Fix several datatype input functions that were allowing unused bytes in their
results to contain uninitialized, unpredictable values. While this was okay as far as the datatypes themselves were concerned, it's a problem for the parser because occurrences of the "same" literal might not be recognized as equal by datumIsEqual (and hence not by equal()). It seems sufficient to fix this in the input functions since the only critical use of equal() is in the parser's comparisons of ORDER BY and DISTINCT expressions. Per a trouble report from Marc Cousin. Patch all the way back. Interestingly, array_in did not have the bug before 8.2, which may explain why the issue went unnoticed for so long.
-rw-r--r--contrib/ltree/ltree_io.c7
-rw-r--r--src/backend/utils/adt/geo_ops.c4
2 files changed, 6 insertions, 5 deletions
diff --git a/contrib/ltree/ltree_io.c b/contrib/ltree/ltree_io.c
index 99803059f0f..0538c2bb263 100644
--- a/contrib/ltree/ltree_io.c
+++ b/contrib/ltree/ltree_io.c
@@ -117,7 +117,7 @@ ltree_in(PG_FUNCTION_ARGS)
errmsg("syntax error"),
errdetail("Unexpected end of line.")));
- result = (ltree *) palloc(LTREE_HDRSIZE + totallen);
+ result = (ltree *) palloc0(LTREE_HDRSIZE + totallen);
result->len = LTREE_HDRSIZE + totallen;
result->numlevel = lptr - list;
curlevel = LTREE_FIRST(result);
@@ -207,8 +207,7 @@ lquery_in(PG_FUNCTION_ARGS)
}
num++;
- curqlevel = tmpql = (lquery_level *) palloc(ITEMSIZE * num);
- memset((void *) tmpql, 0, ITEMSIZE * num);
+ curqlevel = tmpql = (lquery_level *) palloc0(ITEMSIZE * num);
ptr = buf;
while (*ptr)
{
@@ -447,7 +446,7 @@ lquery_in(PG_FUNCTION_ARGS)
curqlevel = NEXTLEV(curqlevel);
}
- result = (lquery *) palloc(totallen);
+ result = (lquery *) palloc0(totallen);
result->len = totallen;
result->numlevel = num;
result->firstgood = 0;
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c
index ca89a8e3e9a..dd80f2f8f30 100644
--- a/src/backend/utils/adt/geo_ops.c
+++ b/src/backend/utils/adt/geo_ops.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.88.4.1 2007/12/18 00:04:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.88.4.2 2008/04/11 22:53:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1375,6 +1375,8 @@ path_in(PG_FUNCTION_ARGS)
errmsg("invalid input syntax for type path: \"%s\"", str)));
path->closed = (!isopen);
+ /* prevent instability in unused pad bytes */
+ path->dummy = 0;
PG_RETURN_PATH_P(path);
}