[PATCH] Add error message for out-of-memory in passwordFromFile() - Mailing list pgsql-hackers

From Joshua Shanks
Subject [PATCH] Add error message for out-of-memory in passwordFromFile()
Date
Msg-id CAOxqWDfihFRmhNVdfu8epYTXQRxkCHSOrg+=-ij2c_X3gW=o3g@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] Add error message for out-of-memory in passwordFromFile()
List pgsql-hackers
Hi,

I noticed a XXX comment in fe-connect.c at line 8064 indicating that an error message would be nice when strdup() fails while reading the password file. Currently, passwordFromFile() silently returns NULL on allocation failure, leaving users without feedback on what went wrong.

This patch adds proper error reporting by:

1. Adding a PGconn *conn parameter to passwordFromFile() to enable error reporting via libpq_append_conn_error()
2. Reporting "out of memory" when strdup() fails, following the pattern used by other OOM handlers in fe-connect.c

The conn parameter is placed first, consistent with the object-oriented convention used throughout libpq (see connectOptions1, fillPGconn, store_conn_addrinfo, etc.).

Cheers,
Joshua
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Improving the names generated for indexes on expressions
Next
From: Michael Paquier
Date:
Subject: Re: [PATCH] Add error message for out-of-memory in passwordFromFile()