diff --git a/src/restore.c b/src/restore.c index 38fa11ed..7efd433a 100644 --- a/src/restore.c +++ b/src/restore.c @@ -219,6 +219,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt, } } } + pg_free(missing_backup_id); /* No point in doing futher */ elog(ERROR, "%s of backup %s failed.", action, base36enc(dest_backup->start_time)); } @@ -255,6 +256,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt, } } } + pg_free(parent_backup_id); tmp_backup = find_parent_full_backup(dest_backup); /* sanity */ diff --git a/src/validate.c b/src/validate.c index 56fa699b..472f7246 100644 --- a/src/validate.c +++ b/src/validate.c @@ -382,7 +382,6 @@ do_validate_all(void) static void do_validate_instance(void) { - char *current_backup_id; int i; int j; parray *backups; @@ -397,7 +396,6 @@ do_validate_instance(void) for (i = 0; i < parray_num(backups); i++) { pgBackup *base_full_backup; - char *parent_backup_id; current_backup = (pgBackup *) parray_get(backups, i); @@ -412,6 +410,7 @@ do_validate_instance(void) /* chain is broken */ if (result == 0) { + char *parent_backup_id; /* determine missing backup ID */ parent_backup_id = base36enc_dup(tmp_backup->parent_backup); @@ -430,31 +429,31 @@ do_validate_instance(void) elog(WARNING, "Backup %s has missing parent %s", base36enc(current_backup->start_time), parent_backup_id); } + pg_free(parent_backup_id); continue; } /* chain is whole, but at least one parent is invalid */ else if (result == 1) { - /* determine corrupt backup ID */ - parent_backup_id = base36enc_dup(tmp_backup->start_time); - /* Oldest corrupt backup has a chance for revalidation */ if (current_backup->start_time != tmp_backup->start_time) { + char *backup_id = base36enc_dup(tmp_backup->start_time); /* orphanize current_backup */ if (current_backup->status == BACKUP_STATUS_OK) { write_backup_status(current_backup, BACKUP_STATUS_ORPHAN); elog(WARNING, "Backup %s is orphaned because his parent %s has status: %s", - base36enc(current_backup->start_time), parent_backup_id, + base36enc(current_backup->start_time), backup_id, status2str(tmp_backup->status)); } else { elog(WARNING, "Backup %s has parent %s with status: %s", - base36enc(current_backup->start_time),parent_backup_id, + base36enc(current_backup->start_time), backup_id, status2str(tmp_backup->status)); } + pg_free(backup_id); continue; } base_full_backup = find_parent_full_backup(current_backup); @@ -495,6 +494,7 @@ do_validate_instance(void) */ if (current_backup->status != BACKUP_STATUS_OK) { + char *current_backup_id; /* This is ridiculous but legal. * PAGE_b2 <- OK * PAGE_a2 <- OK