[PATCH] Fix incorrect fprintf usage in log_error FRONTEND path

From: Bryan Green <dbryan(dot)green(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] Fix incorrect fprintf usage in log_error FRONTEND path
Date: 2025-10-13 15:32:37
Message-ID: CAF+pBj8goe4fRmZ0V3Cs6eyWzYLvK+HvFLYEYWG=TzaM+tWPnw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I noticed that the log_error() utility function has a bug in its FRONTEND
code path. The function uses fprintf() with a va_list argument, but
fprintf() expects individual arguments. This should
be vfprintf() instead.

The relevant code:

#else
fprintf(stderr, fmt, ap);
#endif

Should be:

#else
vfprintf(stderr, fmt, ap);
#endif

While this code path may not currently be compiled in practice, it would
cause compilation warnings or runtime crashes if the FRONTEND macro is ever
defined for files containing this function.

I've attached a patch that fixes this issue.

Bryan Green

Attachment Content-Type Size
0001-Fix-incorrect-fprintf-usage-in-log_error-FRONTEND-pa.patch application/octet-stream 1.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-10-13 15:48:59 Re: [PATCH] Fix incorrect fprintf usage in log_error FRONTEND path
Previous Message jian he 2025-10-13 15:26:46 Re: add function argument name to substring and substr