Initialize t_self and t_tableOid in statext_expressions_load
authorTomas Vondra <tomas.vondra@postgresql.org>
Tue, 13 Apr 2021 22:46:12 +0000 (00:46 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Tue, 13 Apr 2021 22:46:12 +0000 (00:46 +0200)
The function is building a fake heap tuple, but left some of the header
fields (tid and table OID) uninitialized. Per Coverity report.

Reported-by: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQApj6h8tZ0-eP5Af5PKc5NG1YUc7=SdN_99YoHS51fKa0Q@mail.gmail.com

src/backend/statistics/extended_stats.c

index 4bbd85f401ece3eb829072a0bf4484cb6dd8f3ce..e54e8aa8e0f550975d37c899ae16eb7a25e11347 100644 (file)
@@ -2420,6 +2420,8 @@ statext_expressions_load(Oid stxoid, int idx)
 
    /* Build a temporary HeapTuple control structure */
    tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
+   ItemPointerSetInvalid(&(tmptup.t_self));
+   tmptup.t_tableOid = InvalidOid;
    tmptup.t_data = td;
 
    tup = heap_copytuple(&tmptup);