Skip to content

Commit 7685963

Browse files
committed
Handle PQresultErrorField(PG_DIAG_SQLSTATE) returning NULL in streamutil.c.
In ff27db5 I missed that PQresultErrorField() may return NULL if there's no sqlstate associated with an error. Spotted-By: Coverity Reported-By: Michael Paquier Discussion: CAB7nPqQ3o10SY6NVdU4pjq85GQTN5tbbkq2gnNUh2fBNU3rKyQ@mail.gmail.com Backpatch: 9.5, like ff27db5
1 parent d25fbf9 commit 7685963

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/bin/pg_basebackup/streamutil.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
340340
{
341341
const char *sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
342342

343-
if (slot_exists_ok && strcmp(sqlstate, ERRCODE_DUPLICATE_OBJECT) == 0)
343+
if (slot_exists_ok &&
344+
sqlstate &&
345+
strcmp(sqlstate, ERRCODE_DUPLICATE_OBJECT) == 0)
344346
{
345347
destroyPQExpBuffer(query);
346348
PQclear(res);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy