aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-12-08 23:57:03 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-12-08 23:57:03 +0000
commit376784cf8ac7dee831471d7fd4159145d135636b (patch)
tree62008e893458d778777a871f672c5545d5c9b241 /src/backend/access
parentfb47385fc8d2314dd7d23d691959c882ead1c31a (diff)
downloadpostgresql-376784cf8ac7dee831471d7fd4159145d135636b.tar.gz
postgresql-376784cf8ac7dee831471d7fd4159145d135636b.zip
Repair erroneous use of hashvarlena() for MACADDR, which is not a
varlena type. (I did not force initdb, but you won't see the fix unless you do one.) Also, make sure all index support operators and functions are careful not to leak memory for toasted inputs; I had missed some hash and rtree support ops on this point before.
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/hash/hashfunc.c10
-rw-r--r--src/backend/access/rtree/rtproc.c5
2 files changed, 12 insertions, 3 deletions
diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c
index 362738e6764..d431cbafa23 100644
--- a/src/backend/access/hash/hashfunc.c
+++ b/src/backend/access/hash/hashfunc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.27 2000/06/19 03:54:17 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.28 2000/12/08 23:57:02 tgl Exp $
*
* NOTES
* These functions are stored in pg_amproc. For each operator class
@@ -106,8 +106,14 @@ Datum
hashvarlena(PG_FUNCTION_ARGS)
{
struct varlena *key = PG_GETARG_VARLENA_P(0);
+ Datum result;
- return hash_any(VARDATA(key), VARSIZE(key) - VARHDRSZ);
+ result = hash_any(VARDATA(key), VARSIZE(key) - VARHDRSZ);
+
+ /* Avoid leaking memory for toasted inputs */
+ PG_FREE_IF_COPY(key, 0);
+
+ return result;
}
diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c
index dfe5805a6b0..6ee95fbc445 100644
--- a/src/backend/access/rtree/rtproc.c
+++ b/src/backend/access/rtree/rtproc.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.29 2000/07/30 20:43:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.30 2000/12/08 23:57:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -183,5 +183,8 @@ rt_poly_size(PG_FUNCTION_ARGS)
*size = (float) (xdim * ydim);
}
+ /* Avoid leaking memory when handed toasted input. */
+ PG_FREE_IF_COPY(a, 0);
+
PG_RETURN_VOID();
}