pgsql: relcache: Avoid memory leak on tables with no CHECK constraints

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: relcache: Avoid memory leak on tables with no CHECK constraints
Date: 2025-05-11 13:23:17
Message-ID: E1uE6eC-001DVE-1x@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

relcache: Avoid memory leak on tables with no CHECK constraints

As complained about by Valgrind, in commit a379061a22a8 I failed to
realize that I was causing rd_att->constr->check to become allocated
when no CHECK constraints exist; previously it'd remain NULL. (This was
my bug, not the mentioned commit author's). Fix by making the
allocation conditional, and set ->check to NULL if unallocated.

Reported-by: Yasir <yasir(dot)hussain(dot)shah(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/202505082025.57ijx3qrbx7u@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dc9a2d54fd2571c21c074103cc8ddd93e840b985

Modified Files
--------------
src/backend/utils/cache/relcache.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2025-05-11 13:52:57 pgsql: Fix comment of tsquerysend()
Previous Message Álvaro Herrera 2025-05-11 13:16:07 pgsql: Sort includes in alphabetical order