Re: Potential null pointer dereference in postgres.c

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Karina Litskevich <litskevichkarina@gmail.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-05T17:23:14Z
Lists: pgsql-hackers
Karina Litskevich <litskevichkarina@gmail.com> writes:
> When backporting 66e94448 to older versions it was forgotten to check
> malloc() result. In 16+ versions guc_malloc() is used to allocate
> memory and it checks if the result pointer is NULL, so there is no
> need to check it after guc_malloc(). Versions before 16 have no
> guc_malloc(), and malloc() is used instead, but we have to check if
> return value is NULL.

Yup, you're right.  Thanks for the report!

			regards, tom lane



Commits

  1. Avoid low-probability crash on out-of-memory.