postgresql/src
Andres Freund 92fc127878 Fix error handling in libpqrcv_connect()
When libpqrcv_connect (also known as walrcv_connect()) failed, it leaked the
libpq connection. In most paths that's fairly harmless, as the calling process
will exit soon after. But e.g. CREATE SUBSCRIPTION could lead to a somewhat
longer lived leak.

Fix by releasing resources, including the libpq connection, on error.

Add a test exercising the error code path. To make it reliable and safe, the
test tries to connect to port=-1, which happens to fail during connection
establishment, rather than during connection string parsing.

Reviewed-by: Noah Misch <noah@leadboat.com>
Discussion: https://postgr.es/m/20230121011237.q52apbvlarfv6jm6@awork3.anarazel.de
Backpatch: 11-
2023-01-23 18:27:55 -08:00
..
backend Fix error handling in libpqrcv_connect() 2023-01-23 18:27:55 -08:00
bin Fix failure with perlcritic in psql's create_help.pl 2023-01-19 10:02:13 +09:00
common Inhibit mingw CRT's auto-globbing of command line arguments 2022-04-25 15:50:07 -04:00
fe_utils Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
include Make our back branches build under -fkeep-inline-functions. 2023-01-20 11:58:12 -05:00
interfaces Fix comment in fe-auth-scram.c 2022-11-30 08:38:36 +09:00
makefiles Select CFLAGS_SL at configure time, not in platform-specific Makefiles. 2019-10-21 12:32:35 -04:00
pl perl: Hide warnings inside perl.h when using gcc compatible compiler 2023-01-02 15:51:03 -08:00
port Re-allow building on Microsoft Visual Studio 2013. 2022-11-10 10:23:49 -05:00
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:29:13 -04:00
test Fix error handling in libpqrcv_connect() 2023-01-23 18:27:55 -08:00
timezone Update time zone data files to tzdata release 2022f. 2022-11-01 17:09:09 -04:00
tools Fix binary mismatch for MSVC plperl vs gcc built perl libs 2022-11-27 09:18:40 -05:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Prevent port collisions between concurrent TAP tests 2022-11-22 10:52:42 -05:00
Makefile.shlib Fix pkg-config files for static linking 2021-09-06 09:43:18 +02:00
nls-global.mk NLS: Fix backend gettext triggers 2019-09-23 09:05:50 +02:00