Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4ed22e8

Browse files
committed
Check get_tle_by_resno() result before deref
When creating a sort to support a group by, we need to look up thetarget entry in the target list by the resno using get_tle_by_resno().This particular code-path didn't check the result prior to attemptingto dereference it, while all other callers did. While I can't see away for this usage of get_tle_by_resno() to fail (you can't ask fora column to be sorted on which isn't included in the group by), it'sprobably best to check that we didn't end up with a NULL somehowanyway than risk the segfault.I'm willing to back-patch this if others feel it's necessary, but myguess is new features are what might tickle this rather than anythingexisting.Missing check spotted by the Coverity scanner.
1 parent4403a9d commit4ed22e8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎src/backend/optimizer/plan/createplan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4188,6 +4188,9 @@ make_sort_from_groupcols(PlannerInfo *root,
41884188
SortGroupClause*grpcl= (SortGroupClause*)lfirst(l);
41894189
TargetEntry*tle=get_tle_by_resno(sub_tlist,grpColIdx[numsortkeys]);
41904190

4191+
if (!tle)
4192+
elog(ERROR,"could not retrive tle for sort-from-groupcols");
4193+
41914194
sortColIdx[numsortkeys]=tle->resno;
41924195
sortOperators[numsortkeys]=grpcl->sortop;
41934196
collations[numsortkeys]=exprCollation((Node*)tle->expr);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp