Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b362d14

Browse files
Fix memory leaks in error reporting with LOG level
When loglevel is set to LOG, allocated strings used in the error message would leak. Fix by explicitly pfreeing them. Author: Ranier Vilela <ranier.vf@gmail.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAEudQAqMeE0AHcOsOzZx51Z0eiFJAjhBPRFt+Bxi3ETXWen7ig@mail.gmail.com
1 parent ab4d7a3 commit b362d14

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/backend/archive/shell_archive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ shell_archive_file(ArchiveModuleState *state, const char *file,
125125
errdetail("The failed archive command was: %s",
126126
xlogarchcmd)));
127127
}
128+
pfree(xlogarchcmd);
128129

129130
return false;
130131
}
132+
pfree(xlogarchcmd);
131133

132134
elog(DEBUG1, "archived write-ahead log file \"%s\"", file);
133135
return true;

src/backend/libpq/be-secure-common.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf,
8585
}
8686
else if (pclose_rc != 0)
8787
{
88+
char *reason;
89+
8890
explicit_bzero(buf, size);
91+
reason = wait_result_to_str(pclose_rc);
8992
ereport(loglevel,
9093
(errcode_for_file_access(),
9194
errmsg("command \"%s\" failed",
9295
command),
93-
errdetail_internal("%s", wait_result_to_str(pclose_rc))));
96+
errdetail_internal("%s", reason)));
97+
pfree(reason);
9498
goto error;
9599
}
96100

0 commit comments

Comments
 (0)