summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-protocol3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/libpq/fe-protocol3.c')
-rw-r--r--src/interfaces/libpq/fe-protocol3.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index 2e833053487..9ab3bf1fcb6 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -967,12 +967,12 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
if (isError)
{
if (res)
- res->errMsg = pqResultStrdup(res, workBuf.data);
+ pqSetResultError(res, &workBuf);
pqClearAsyncResult(conn); /* redundant, but be safe */
conn->result = res;
if (PQExpBufferDataBroken(workBuf))
appendPQExpBufferStr(&conn->errorMessage,
- libpq_gettext("out of memory"));
+ libpq_gettext("out of memory\n"));
else
appendPQExpBufferStr(&conn->errorMessage, workBuf.data);
}
@@ -981,8 +981,15 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
/* if we couldn't allocate the result set, just discard the NOTICE */
if (res)
{
- /* We can cheat a little here and not copy the message. */
- res->errMsg = workBuf.data;
+ /*
+ * We can cheat a little here and not copy the message. But if we
+ * were unlucky enough to run out of memory while filling workBuf,
+ * insert "out of memory", as in pqSetResultError.
+ */
+ if (PQExpBufferDataBroken(workBuf))
+ res->errMsg = libpq_gettext("out of memory\n");
+ else
+ res->errMsg = workBuf.data;
if (res->noticeHooks.noticeRec != NULL)
res->noticeHooks.noticeRec(res->noticeHooks.noticeRecArg, res);
PQclear(res);