summaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_utils_num.h
diff options
context:
space:
mode:
authorTom Lane2014-05-16 19:11:51 +0000
committerTom Lane2014-05-16 19:11:51 +0000
commit82bbb60c30dbff0633da34387ccab58d843379b5 (patch)
tree3a3ea1b1da2dfe6f0a80c97cd6fd7f3d79e83717 /contrib/btree_gist/btree_utils_num.h
parentd900e192a3ef2dd73fae4522c35aadce6d72a534 (diff)
Fix valgrind warning for btree_gist indexes on macaddr.
The macaddr opclass stores two macaddr structs (each of size 6) in an index column that's declared as being of type gbtreekey16, ie 16 bytes. In the original coding this led to passing a palloc'd value of size 12 to the index insertion code, so that data would be fetched past the end of the allocated value during index tuple construction. This makes valgrind unhappy. In principle it could result in a SIGSEGV, though with the current implementation of palloc there's no risk since the 12-byte request size would be rounded up to 16 bytes anyway. To fix, add a field to struct gbtree_ninfo showing the declared size of the index datums, and use that in the palloc requests; and use palloc0 to be sure that any wasted bytes are cleanly initialized. Per report from Andres Freund. No back-patch since there's no current risk of a real problem.
Diffstat (limited to 'contrib/btree_gist/btree_utils_num.h')
-rw-r--r--contrib/btree_gist/btree_utils_num.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h
index d7a61d22426..0d79cd2a7f7 100644
--- a/contrib/btree_gist/btree_utils_num.h
+++ b/contrib/btree_gist/btree_utils_num.h
@@ -37,7 +37,8 @@ typedef struct
/* Attribs */
enum gbtree_type t; /* data type */
- int32 size; /* size of type , 0 means variable */
+ int32 size; /* size of type, 0 means variable */
+ int32 indexsize; /* size of datums stored in index */
/* Methods */