From: Tom Lane Date: Wed, 10 Jun 2026 21:01:45 +0000 (-0400) Subject: Undo thinko in commit e78d1d6d4. X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=9d141466ff087230571e9c9dfd720deb94977253;p=thirdparty%2Fpostgresql.git Undo thinko in commit e78d1d6d4. In pursuit of removing a Valgrind-detected leak, I inserted "pfree(pq_mq_handle);" into mq_putmessage's recursion-trouble-recovery code path, failing to notice that shm_mq_detach would have pfree'd that block just before (i.e., this particular code path did not leak). So now that was a double pfree. We didn't notice because the recursion scenario isn't exercised in our regression tests, but Alexander Lakhin found it via code fuzzing. Reported-by: Alexander Lakhin Author: Tom Lane Discussion: https://postgr.es/m/b8b40954-e155-41b3-9af8-ad4f261a1b64@gmail.com --- diff --git a/src/backend/libpq/pqmq.c b/src/backend/libpq/pqmq.c index 21ce180c78d..d038a9da515 100644 --- a/src/backend/libpq/pqmq.c +++ b/src/backend/libpq/pqmq.c @@ -140,7 +140,6 @@ mq_putmessage(char msgtype, const char *s, size_t len) if (pq_mq_handle != NULL) { shm_mq_detach(pq_mq_handle); - pfree(pq_mq_handle); pq_mq_handle = NULL; } return EOF;