Commit 2b526ed2 authored by Alvaro Herrera's avatar Alvaro Herrera

Fix new memory leaks in libpq

My oversight in commit 9aa491ab.

Per coverity.
parent 677271a3
...@@ -1299,10 +1299,6 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery) ...@@ -1299,10 +1299,6 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery)
if (!PQsendQueryStart(conn, newQuery)) if (!PQsendQueryStart(conn, newQuery))
return 0; return 0;
entry = pqAllocCmdQueueEntry(conn);
if (entry == NULL)
return 0; /* error msg already set */
/* check the argument */ /* check the argument */
if (!query) if (!query)
{ {
...@@ -1311,6 +1307,10 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery) ...@@ -1311,6 +1307,10 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery)
return 0; return 0;
} }
entry = pqAllocCmdQueueEntry(conn);
if (entry == NULL)
return 0; /* error msg already set */
/* Send the query message(s) */ /* Send the query message(s) */
if (conn->pipelineStatus == PQ_PIPELINE_OFF) if (conn->pipelineStatus == PQ_PIPELINE_OFF)
{ {
...@@ -1320,6 +1320,7 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery) ...@@ -1320,6 +1320,7 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery)
pqPutMsgEnd(conn) < 0) pqPutMsgEnd(conn) < 0)
{ {
/* error message should be set up already */ /* error message should be set up already */
pqRecycleCmdQueueEntry(conn, entry);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment