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
This commit is contained in:
parent
ab4d7a38c3
commit
b362d14816
@ -125,9 +125,11 @@ shell_archive_file(ArchiveModuleState *state, const char *file,
|
|||||||
errdetail("The failed archive command was: %s",
|
errdetail("The failed archive command was: %s",
|
||||||
xlogarchcmd)));
|
xlogarchcmd)));
|
||||||
}
|
}
|
||||||
|
pfree(xlogarchcmd);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
pfree(xlogarchcmd);
|
||||||
|
|
||||||
elog(DEBUG1, "archived write-ahead log file \"%s\"", file);
|
elog(DEBUG1, "archived write-ahead log file \"%s\"", file);
|
||||||
return true;
|
return true;
|
||||||
|
@ -85,12 +85,16 @@ run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf,
|
|||||||
}
|
}
|
||||||
else if (pclose_rc != 0)
|
else if (pclose_rc != 0)
|
||||||
{
|
{
|
||||||
|
char *reason;
|
||||||
|
|
||||||
explicit_bzero(buf, size);
|
explicit_bzero(buf, size);
|
||||||
|
reason = wait_result_to_str(pclose_rc);
|
||||||
ereport(loglevel,
|
ereport(loglevel,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("command \"%s\" failed",
|
errmsg("command \"%s\" failed",
|
||||||
command),
|
command),
|
||||||
errdetail_internal("%s", wait_result_to_str(pclose_rc))));
|
errdetail_internal("%s", reason)));
|
||||||
|
pfree(reason);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user