From: Andres Freund Date: Wed, 30 Oct 2019 02:18:07 +0000 (-0700) Subject: pg_waldump: Fix small memory leak when rmgr->rm_identify returns NULL. X-Git-Tag: REL_11_6~31 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=af67aee69189c59bd3076b472f959a16e6193828;p=postgresql.git pg_waldump: Fix small memory leak when rmgr->rm_identify returns NULL. This got broken in 604f7956b94, shortly after rm_identify's introduction. Author: Andres Freund Discussion: https://postgr.es/m/20191029233341.4gnyau7e5v2lh5sc@alap3.anarazel.de Backpatch: 9.5, where rm_identify was introduced --- diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 2f40c559adf..4e1df66c48a 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -542,17 +542,18 @@ XLogDumpDisplayRecord(XLogDumpConfig *config, XLogReaderState *record) XLogDumpRecordLen(record, &rec_len, &fpi_len); - id = desc->rm_identify(info); - if (id == NULL) - id = psprintf("UNKNOWN (%x)", info & ~XLR_INFO_MASK); - printf("rmgr: %-11s len (rec/tot): %6u/%6u, tx: %10u, lsn: %X/%08X, prev %X/%08X, ", desc->rm_name, rec_len, XLogRecGetTotalLen(record), XLogRecGetXid(record), (uint32) (record->ReadRecPtr >> 32), (uint32) record->ReadRecPtr, (uint32) (xl_prev >> 32), (uint32) xl_prev); - printf("desc: %s ", id); + + id = desc->rm_identify(info); + if (id == NULL) + printf("desc: UNKNOWN (%x) ", info & ~XLR_INFO_MASK); + else + printf("desc: %s ", id); /* the desc routine will printf the description directly to stdout */ desc->rm_desc(NULL, record);