Skip to content

Commit 1acf0c5

Browse files
committed
Free base36enc's result in validate_wal() and do_validate_instance()
1 parent 126c424 commit 1acf0c5

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

parsexlog.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ validate_wal(pgBackup *backup,
274274
TimeLineID tli)
275275
{
276276
XLogRecPtr startpoint = backup->start_lsn;
277+
char *backup_id;
277278
XLogRecord *record;
278279
XLogReaderState *xlogreader;
279280
char *errormsg;
@@ -283,17 +284,20 @@ validate_wal(pgBackup *backup,
283284
char last_timestamp[100],
284285
target_timestamp[100];
285286
bool all_wal = false;
286-
char backup_xlog_path[MAXPGPATH];
287+
char backup_xlog_path[MAXPGPATH];
288+
289+
/* We need free() this later */
290+
backup_id = base36enc(backup->start_time);
287291

288292
if (!XRecOffIsValid(backup->start_lsn))
289293
elog(ERROR, "Invalid start_lsn value %X/%X of backup %s",
290294
(uint32) (backup->start_lsn >> 32), (uint32) (backup->start_lsn),
291-
base36enc(backup->start_time));
295+
backup_id);
292296

293297
if (!XRecOffIsValid(backup->stop_lsn))
294298
elog(ERROR, "Invalid stop_lsn value %X/%X of backup %s",
295299
(uint32) (backup->stop_lsn >> 32), (uint32) (backup->stop_lsn),
296-
base36enc(backup->start_time));
300+
backup_id);
297301

298302
/*
299303
* Check that the backup has all wal files needed
@@ -302,13 +306,15 @@ validate_wal(pgBackup *backup,
302306
if (backup->stream)
303307
{
304308
sprintf(backup_xlog_path, "/%s/%s/%s/%s",
305-
backup_instance_path, base36enc(backup->start_time), DATABASE_DIR, PG_XLOG_DIR);
309+
backup_instance_path, backup_id, DATABASE_DIR, PG_XLOG_DIR);
306310

307311
validate_backup_wal_from_start_to_stop(backup, backup_xlog_path, tli);
308312
}
309313
else
310314
validate_backup_wal_from_start_to_stop(backup, (char *) archivedir, tli);
311315

316+
free(backup_id);
317+
312318
/* If recovery target is provided, ensure that archive exists. */
313319
if (dir_is_empty(archivedir)
314320
&& (TransactionIdIsValid(target_xid) || target_time != 0))

validate.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pgBackupValidate(pgBackup *backup)
4040
validate_files_args *validate_threads_args[num_threads];
4141
int i;
4242

43+
/* We need free() this later */
4344
backup_id_string = base36enc(backup->start_time);
4445

4546
if (backup->status != BACKUP_STATUS_OK &&
@@ -260,8 +261,14 @@ do_validate_instance(void)
260261
/* Valiate each backup along with its xlog files. */
261262
for (i = 0; i < parray_num(backups); i++)
262263
{
264+
char *backup_id;
265+
263266
current_backup = (pgBackup *) parray_get(backups, i);
264-
elog(INFO, "Validate backup %s", base36enc(current_backup->start_time));
267+
backup_id = base36enc(current_backup->start_time);
268+
269+
elog(INFO, "Validate backup %s", backup_id);
270+
271+
free(backup_id);
265272

266273
if (current_backup->backup_mode != BACKUP_MODE_FULL)
267274
{

0 commit comments

Comments
 (0)