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

Commitc6605c1

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 parenta37bb7c commitc6605c1

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
@@ -842,6 +842,8 @@ pqSaveWriteError(PGconn *conn)
842842
* using whatever is in conn->errorMessage. In any case, clear the async
843843
* result storage, and update our notion of how much error text has been
844844
* returned to the application.
845+
*
846+
* Note that in no case (not even OOM) do we return NULL.
845847
*/
846848
PGresult*
847849
pqPrepareAsyncResult(PGconn*conn)
@@ -2138,7 +2140,7 @@ PQgetResult(PGconn *conn)
21382140
* (In other words: we don't return a NULL after a pipeline
21392141
* sync.)
21402142
*/
2141-
if (res&&res->resultStatus==PGRES_PIPELINE_SYNC)
2143+
if (res->resultStatus==PGRES_PIPELINE_SYNC)
21422144
pqPipelineProcessQueue(conn);
21432145
}
21442146
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp