From 28f5332b50a7cf11f16d35b2860628e58077c239 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Mon, 6 Oct 2025 08:45:03 +0900 Subject: [PATCH v1] Fix Coverity issues reported in commit 25a30bbd423. This commit fixes several issues pointed out by Coverity. - In row_is_in_frame(), return value of window_gettupleslot() was not checked. - WinGetFuncArgInPartition() tried to derefference "isout" pointer even if it's NULL in some places. Discussion: https://postgr.es/m/202510051612.gw67jlc2iqpw%40alvherre.pgsql --- src/backend/executor/nodeWindowAgg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c index cf667c81211..7ccf1160dca 100644 --- a/src/backend/executor/nodeWindowAgg.c +++ b/src/backend/executor/nodeWindowAgg.c @@ -1501,8 +1501,9 @@ row_is_in_frame(WindowObject winobj, int64 pos, TupleTableSlot *slot, /* following row that is not peer is out of frame */ if (pos > winstate->currentpos) { - if (fetch_tuple) - window_gettupleslot(winobj, pos, slot); + if (fetch_tuple) /* need to fetch tuple? */ + if (!window_gettupleslot(winobj, pos, slot)) + return -1; if (!are_peers(winstate, slot, winstate->ss.ss_ScanTupleSlot)) return -1; } @@ -3761,7 +3762,7 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno, { datum = gettuple_eval_partition(winobj, argno, abs_pos, isnull, isout); - if (!*isout && set_mark) + if (isout && !*isout && set_mark) WinSetMarkPosition(winobj, abs_pos); return datum; } @@ -3803,7 +3804,7 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno, default: /* need to check NULL or not */ datum = gettuple_eval_partition(winobj, argno, abs_pos, isnull, isout); - if (*isout) /* out of partition? */ + if (isout && *isout) /* out of partition? */ return datum; if (!*isnull) @@ -3814,7 +3815,7 @@ WinGetFuncArgInPartition(WindowObject winobj, int argno, } } while (notnull_offset < notnull_relpos); - if (!*isout && set_mark) + if (isout && !*isout && set_mark) WinSetMarkPosition(winobj, abs_pos); return datum; -- 2.43.0