From 67b451aa4591fe847f249f8a5313a5e9e7a30b1e Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Fri, 12 Jul 2013 08:01:01 -0500 Subject: [PATCH] If PQgetCancel() returns NULL we should also return false. Noted by Andres Freund. --- dbutils.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dbutils.c b/dbutils.c index 0aef3964..96ba5530 100644 --- a/dbutils.c +++ b/dbutils.c @@ -443,22 +443,22 @@ CancelQuery(PGconn *conn, int timeout) pgcancel = PQgetCancel(conn); - if (pgcancel != NULL) - { - /* - * PQcancel can only return 0 if socket()/connect()/send() - * fails, in any of those cases we can assume something - * bad happened to the connection - */ - if (PQcancel(pgcancel, errbuf, ERRBUFF_SIZE) == 0) - { - log_warning(_("Can't stop current query: %s\n"), errbuf); - PQfreeCancel(pgcancel); - return false; - } + if (pgcancel == NULL) + return false; + /* + * PQcancel can only return 0 if socket()/connect()/send() + * fails, in any of those cases we can assume something + * bad happened to the connection + */ + if (PQcancel(pgcancel, errbuf, ERRBUFF_SIZE) == 0) + { + log_warning(_("Can't stop current query: %s\n"), errbuf); PQfreeCancel(pgcancel); + return false; } + PQfreeCancel(pgcancel); + return true; }