Skip to content

Commit 84fb036

Browse files
committed
fix in pg_stop_backup call on backup interruption
1 parent 098a91f commit 84fb036

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

backup.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,18 @@ pg_stop_backup(pgBackup *backup)
960960
fclose(fp);
961961

962962
/* TODO What for do we save the file into backup_list? */
963-
file = pgFileNew(backup_label, true);
964-
calc_file_checksum(file);
965-
free(file->path);
966-
file->path = strdup(PG_BACKUP_LABEL_FILE);
967-
parray_append(backup_files_list, file);
963+
/*
964+
* It's vital to check if backup_files_list is initialized,
965+
* because we could get here because the backup was interrupted
966+
*/
967+
if (backup_files_list)
968+
{
969+
file = pgFileNew(backup_label, true);
970+
calc_file_checksum(file);
971+
free(file->path);
972+
file->path = strdup(PG_BACKUP_LABEL_FILE);
973+
parray_append(backup_files_list, file);
974+
}
968975

969976
/* Write tablespace_map */
970977
if (strlen(PQgetvalue(res, 0, 2)) > 0)

0 commit comments

Comments
 (0)