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

Commita9d58bf

Browse files
committed
Fix tiny memory leaks
Both check_application_name() and check_cluster_name() usepg_clean_ascii() but didn't release the memory. Depending on when theGUC is set, this might be cleaned up at some later time or it wouldleak postmaster memory once. In any case, it seems better not to haveto rely on such analysis and make the code locally robust. Also, thismakes Valgrind happier.Author: Masahiko Sawada <sawada.mshk@gmail.com>Reviewed-by: Jacob Champion <jchampion@timescale.com>Discussion:https://www.postgresql.org/message-id/CAD21AoBmFNy9MPfA0UUbMubQqH3AaK5U3mrv6pSeWrwCk3LJ8g@mail.gmail.com
1 parent83e42a0 commita9d58bf

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

‎src/backend/commands/variable.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,17 +1025,22 @@ bool
10251025
check_application_name(char**newval,void**extra,GucSourcesource)
10261026
{
10271027
char*clean;
1028+
char*ret;
10281029

10291030
/* Only allow clean ASCII chars in the application name */
10301031
clean=pg_clean_ascii(*newval,MCXT_ALLOC_NO_OOM);
10311032
if (!clean)
10321033
return false;
10331034

1034-
clean=guc_strdup(WARNING,clean);
1035-
if (!clean)
1035+
ret=guc_strdup(WARNING,clean);
1036+
if (!ret)
1037+
{
1038+
pfree(clean);
10361039
return false;
1040+
}
10371041

1038-
*newval=clean;
1042+
pfree(clean);
1043+
*newval=ret;
10391044
return true;
10401045
}
10411046

@@ -1056,17 +1061,22 @@ bool
10561061
check_cluster_name(char**newval,void**extra,GucSourcesource)
10571062
{
10581063
char*clean;
1064+
char*ret;
10591065

10601066
/* Only allow clean ASCII chars in the cluster name */
10611067
clean=pg_clean_ascii(*newval,MCXT_ALLOC_NO_OOM);
10621068
if (!clean)
10631069
return false;
10641070

1065-
clean=guc_strdup(WARNING,clean);
1066-
if (!clean)
1071+
ret=guc_strdup(WARNING,clean);
1072+
if (!ret)
1073+
{
1074+
pfree(clean);
10671075
return false;
1076+
}
10681077

1069-
*newval=clean;
1078+
pfree(clean);
1079+
*newval=ret;
10701080
return true;
10711081
}
10721082

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp