• Tom Lane's avatar
    Fix valgrind warning for btree_gist indexes on macaddr. · 82bbb60c
    Tom Lane authored
    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.
    82bbb60c
btree_int8.c 4.57 KB