Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc9a2d5

Browse files
author
Álvaro Herrera
committed
relcache: Avoid memory leak on tables with no CHECK constraints
As complained about by Valgrind, in commita379061 I failed torealize that I was causing rd_att->constr->check to become allocatedwhen no CHECK constraints exist; previously it'd remain NULL. (This wasmy bug, not the mentioned commit author's). Fix by making theallocation conditional, and set ->check to NULL if unallocated.Reported-by: Yasir <yasir.hussain.shah@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/202505082025.57ijx3qrbx7u@alvherre.pgsql
1 parent7b2ad43 commitdc9a2d5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎src/backend/utils/cache/relcache.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4598,10 +4598,13 @@ CheckNNConstraintFetch(Relation relation)
45984598
HeapTuplehtup;
45994599
intfound=0;
46004600

4601-
/* Allocate array with room for as many entries as expected */
4602-
check= (ConstrCheck*)
4603-
MemoryContextAllocZero(CacheMemoryContext,
4604-
ncheck*sizeof(ConstrCheck));
4601+
/* Allocate array with room for as many entries as expected, if needed */
4602+
if (ncheck>0)
4603+
check= (ConstrCheck*)
4604+
MemoryContextAllocZero(CacheMemoryContext,
4605+
ncheck*sizeof(ConstrCheck));
4606+
else
4607+
check=NULL;
46054608

46064609
/* Search pg_constraint for relevant entries */
46074610
ScanKeyInit(&skey[0],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp