From 92109e4bbad9cdcd86dd9bf2f40bae5c26202a0d Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 5 Jun 2014 13:41:45 +0200 Subject: [PATCH] Correctly handle an empty error message from PQescapeIdentifier --- psycopg/cursor_type.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index fd8fbbee..0a785c05 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -1030,7 +1030,8 @@ _escape_identifier(PGconn *pgconn, const char *str, size_t length) rv = PQescapeIdentifier(pgconn, str, length); if (!rv) { char *msg; - if (!(msg = PQerrorMessage(pgconn))) { + msg = PQerrorMessage(pgconn); + if (!msg || !msg[0]) { msg = "no message provided"; } PyErr_Format(InterfaceError, "failed to escape identifier: %s", msg);