Fix copy-and-past thinko (src/interfaces/libpq/fe-cancel.c)

Started by Ranier Vilela7 months ago4 messages
#1Ranier Vilela
ranier.vf@gmail.com
1 attachment(s)

Hi.

In the function *PQcancelCreate* there is a copy-and-past thinko.
The pointer that must be checked is cancelConn.

Trivial patch attached.

best regards,
Ranier Vilela

Attachments:

fix-copy-and-past-thinko-fe-cancel.patchapplication/octet-stream; name=fix-copy-and-past-thinko-fe-cancel.patchDownload
diff --git a/src/interfaces/libpq/fe-cancel.c b/src/interfaces/libpq/fe-cancel.c
index 8c7c198a53..d6d4f1ba32 100644
--- a/src/interfaces/libpq/fe-cancel.c
+++ b/src/interfaces/libpq/fe-cancel.c
@@ -114,7 +114,7 @@ PQcancelCreate(PGconn *conn)
 	if (conn->be_cancel_key != NULL)
 	{
 		cancelConn->be_cancel_key = malloc(conn->be_cancel_key_len);
-		if (!conn->be_cancel_key)
+		if (cancelconn->be_cancel_key == NULL)
 			goto oom_error;
 		memcpy(cancelConn->be_cancel_key, conn->be_cancel_key, conn->be_cancel_key_len);
 	}
#2Daniel Gustafsson
daniel@yesql.se
In reply to: Ranier Vilela (#1)
Re: Fix copy-and-past thinko (src/interfaces/libpq/fe-cancel.c)

On 17 Jun 2025, at 15:40, Ranier Vilela <ranier.vf@gmail.com> wrote:

In the function *PQcancelCreate* there is a copy-and-past thinko.
The pointer that must be checked is cancelConn.

Trivial patch attached.

Nice catch, will fix.

--
Daniel Gustafsson

#3Ranier Vilela
ranier.vf@gmail.com
In reply to: Daniel Gustafsson (#2)
1 attachment(s)
Re: Fix copy-and-past thinko (src/interfaces/libpq/fe-cancel.c)

Em ter., 17 de jun. de 2025 às 10:42, Daniel Gustafsson <daniel@yesql.se>
escreveu:

On 17 Jun 2025, at 15:40, Ranier Vilela <ranier.vf@gmail.com> wrote:

In the function *PQcancelCreate* there is a copy-and-past thinko.
The pointer that must be checked is cancelConn.

Trivial patch attached.

Nice catch, will fix.

v1 attached, thanks.

best regards,
Ranier Vilela

Attachments:

v1-fix-copy-and-past-thinko-fe-cancel.patchapplication/octet-stream; name=v1-fix-copy-and-past-thinko-fe-cancel.patchDownload
diff --git a/src/interfaces/libpq/fe-cancel.c b/src/interfaces/libpq/fe-cancel.c
index 8c7c198a53..cd3102346b 100644
--- a/src/interfaces/libpq/fe-cancel.c
+++ b/src/interfaces/libpq/fe-cancel.c
@@ -114,7 +114,7 @@ PQcancelCreate(PGconn *conn)
 	if (conn->be_cancel_key != NULL)
 	{
 		cancelConn->be_cancel_key = malloc(conn->be_cancel_key_len);
-		if (!conn->be_cancel_key)
+		if (cancelConn->be_cancel_key == NULL)
 			goto oom_error;
 		memcpy(cancelConn->be_cancel_key, conn->be_cancel_key, conn->be_cancel_key_len);
 	}
#4Ranier Vilela
ranier.vf@gmail.com
In reply to: Daniel Gustafsson (#2)
Re: Fix copy-and-past thinko (src/interfaces/libpq/fe-cancel.c)

Em ter., 17 de jun. de 2025 às 10:42, Daniel Gustafsson <daniel@yesql.se>
escreveu:

On 17 Jun 2025, at 15:40, Ranier Vilela <ranier.vf@gmail.com> wrote:

In the function *PQcancelCreate* there is a copy-and-past thinko.
The pointer that must be checked is cancelConn.

Trivial patch attached.

Nice catch, will fix.

Thanks for the commit, Daniel.

best regards,
Ranier Vilela