diff options
author | Andres Freund <andres@anarazel.de> | 2015-08-12 17:09:35 +0200 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2015-08-12 17:35:57 +0200 |
commit | 2e6f6f3abe6fd249cc8a4d5eb194295ac3988b19 (patch) | |
tree | b204dac4ab3635341d6a2e57d9eedc2f4804667c | |
parent | 43a8ed26c97e36d971b6018d1bc94ad5c52d169b (diff) | |
download | postgresql-2e6f6f3abe6fd249cc8a4d5eb194295ac3988b19.tar.gz postgresql-2e6f6f3abe6fd249cc8a4d5eb194295ac3988b19.zip |
Handle PQresultErrorField(PG_DIAG_SQLSTATE) returning NULL in streamutil.c.
In ff27db5d 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 ff27db5d
-rw-r--r-- | src/bin/pg_basebackup/streamutil.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 91f919c34cd..2c963b67a32 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -340,7 +340,9 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin, { const char *sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE); - if (slot_exists_ok && strcmp(sqlstate, ERRCODE_DUPLICATE_OBJECT) == 0) + if (slot_exists_ok && + sqlstate && + strcmp(sqlstate, ERRCODE_DUPLICATE_OBJECT) == 0) { destroyPQExpBuffer(query); PQclear(res); |