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

Commitdc4da3d

Browse files
committed
Fix very minor memory leaks in psql's command.c.
\drds leaked its second pattern argument if any, and \connect leakedany empty-string or "-" arguments. These are old bugs, but it's hardto imagine any real use-case where the leaks could amount to anythingmeaningful, so not bothering with a back-patch.Daniel Gustafsson and Tom LaneDiscussion:https://postgr.es/m/3641F19B-336A-431A-86CE-A80562505C5E@yesql.se
1 parentefd7f8e commitdc4da3d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎src/bin/psql/command.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
806806
pattern2=psql_scan_slash_option(scan_state,
807807
OT_NORMAL,NULL, true);
808808
success=listDbRoleSettings(pattern,pattern2);
809+
810+
if (pattern2)
811+
free(pattern2);
809812
}
810813
else
811814
status=PSQL_CMD_UNKNOWN;
@@ -2725,6 +2728,8 @@ exec_command_slash_command_help(PsqlScanState scan_state, bool active_branch)
27252728

27262729
/*
27272730
* Read and interpret an argument to the \connect slash command.
2731+
*
2732+
* Returns a malloc'd string, or NULL if no/empty argument.
27282733
*/
27292734
staticchar*
27302735
read_connect_arg(PsqlScanStatescan_state)
@@ -2750,7 +2755,10 @@ read_connect_arg(PsqlScanState scan_state)
27502755
returnresult;
27512756

27522757
if (*result=='\0'||strcmp(result,"-")==0)
2758+
{
2759+
free(result);
27532760
returnNULL;
2761+
}
27542762

27552763
returnresult;
27562764
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp