Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/bin/pg_autoctl/cli_do_tmux_azure.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ tmux_azure_start_or_attach_session(AzureRegionResources *azRegion)
{
char tmux[MAXPGPATH] = { 0 };

PQExpBuffer script = createPQExpBuffer();
PQExpBuffer script;
char scriptName[MAXPGPATH] = { 0 };

if (setenv("PG_AUTOCTL_DEBUG", "1", 1) != 0)
Expand Down Expand Up @@ -222,6 +222,7 @@ tmux_azure_start_or_attach_session(AzureRegionResources *azRegion)
return false;
}

script = createPQExpBuffer();
if (script == NULL)
{
log_error("Failed to allocate memory");
Expand All @@ -248,12 +249,14 @@ tmux_azure_start_or_attach_session(AzureRegionResources *azRegion)
if (!write_file(script->data, script->len, scriptName))
{
log_fatal("Failed to write tmux script at \"%s\"", scriptName);
destroyPQExpBuffer(script);
return false;
}

if (!tmux_start_server(scriptName))
{
log_fatal("Failed to start the tmux session, see above for details");
destroyPQExpBuffer(script);
return false;
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/bin/pg_autoctl/pgctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,13 +860,20 @@ ensure_default_settings_file_exists(const char *configFilePath,
{
PQExpBuffer defaultConfContents = createPQExpBuffer();

if (defaultConfContents == NULL)
{
log_error("Failed to allocate memory");
return false;
}

if (!prepare_guc_settings_from_pgsetup(configFilePath,
defaultConfContents,
settings,
pgSetup,
includeTuning))
{
/* errors have already been logged */
destroyPQExpBuffer(defaultConfContents);
return false;
}

Expand Down Expand Up @@ -2282,6 +2289,12 @@ prepare_primary_conninfo(char *primaryConnInfo,

PQExpBuffer buffer = createPQExpBuffer();

if (buffer == NULL)
{
log_error("Failed to allocate memory");
return false;
}

/* application_name shows up in pg_stat_replication on the primary */
appendPQExpBuffer(buffer, "application_name=%s", applicationName);
appendPQExpBuffer(buffer, " host=%s", primaryHost);
Expand All @@ -2302,6 +2315,7 @@ prepare_primary_conninfo(char *primaryConnInfo,
if (!prepare_conninfo_sslmode(buffer, sslOptions))
{
/* errors have already been logged */
destroyPQExpBuffer(buffer);
return false;
}

Expand Down Expand Up @@ -2330,6 +2344,7 @@ prepare_primary_conninfo(char *primaryConnInfo,
log_error("BUG: the escaped primary_conninfo requires %d bytes and "
"pg_auto_failover only support up to %d bytes",
size, primaryConnInfoSize);
destroyPQExpBuffer(buffer);
return false;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/bin/pg_autoctl/pghba.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ pghba_ensure_host_rules_exist(const char *hbaFilePath,
if (!read_file(hbaFilePath, &currentHbaContents, &currentHbaSize))
{
/* read_file logs an error */
destroyPQExpBuffer(newHbaContents);
return false;
}

Expand Down Expand Up @@ -317,6 +318,7 @@ pghba_ensure_host_rules_exist(const char *hbaFilePath,

/* done with the old pg_hba.conf contents */
free(currentHbaContents);
destroyPQExpBuffer(newHbaContents);

/* done with the new HBA line buffers */
destroyPQExpBuffer(hbaLineReplicationBuffer);
Expand Down Expand Up @@ -367,6 +369,7 @@ pghba_ensure_host_rules_exist(const char *hbaFilePath,

/* done with the old pg_hba.conf contents */
free(currentHbaContents);
destroyPQExpBuffer(newHbaContents);

/* done with the new HBA line buffers (and safe to call on NULL) */
destroyPQExpBuffer(hbaLineReplicationBuffer);
Expand All @@ -387,6 +390,7 @@ pghba_ensure_host_rules_exist(const char *hbaFilePath,

/* done with the old pg_hba.conf contents */
free(currentHbaContents);
destroyPQExpBuffer(newHbaContents);

/* done with the new HBA line buffers (and safe to call on NULL) */
destroyPQExpBuffer(hbaLineReplicationBuffer);
Expand Down
1 change: 1 addition & 0 deletions src/bin/pg_autoctl/supervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ supervisor_update_pidfile(Supervisor *supervisor)
if (!prepare_pidfile_buffer(content, supervisor->pid))
{
/* errors have already been logged */
destroyPQExpBuffer(content);
return false;
}

Expand Down