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

Commit39aab11

Browse files
committed
Don't test already-referenced pointer for nullness
Commitb8ba734 added in PQgetResult a derefence to a pointerreturned by pqPrepareAsyncResult(), before some other code that wasalready testing that pointer for nullness. But since commit618c167 (in Postgres 15), pqPrepareAsyncResult() doesn't everreturn NULL (a statically-allocated result is returned if OOM). So inbranches 15 and up, we can remove the redundant pointer check with noharm done.However, in branch 14, pqPrepareAsyncResult() can indeed return NULL ifit runs out of memory. Fix things there by adding a null pointer checkbefore dereferencing the pointer. This should hint Coverity that thepreexisting check is not redundant but necessary.Backpatch to 14, likeb8ba734.Per Coverity.
1 parent23e0ba5 commit39aab11

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎src/interfaces/libpq/fe-exec.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,8 @@ pqSaveWriteError(PGconn *conn)
841841
* using whatever is in conn->errorMessage. In any case, clear the async
842842
* result storage, and update our notion of how much error text has been
843843
* returned to the application.
844+
*
845+
* Note that in no case (not even OOM) do we return NULL.
844846
*/
845847
PGresult*
846848
pqPrepareAsyncResult(PGconn*conn)
@@ -2137,7 +2139,7 @@ PQgetResult(PGconn *conn)
21372139
* (In other words: we don't return a NULL after a pipeline
21382140
* sync.)
21392141
*/
2140-
if (res&&res->resultStatus==PGRES_PIPELINE_SYNC)
2142+
if (res->resultStatus==PGRES_PIPELINE_SYNC)
21412143
pqPipelineProcessQueue(conn);
21422144
}
21432145
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp