Fix possible memory leak in rescanLatestTimeLine()
Started by Yugo Nagataover 1 year ago1 messages
In rescanLatestTimeLine(), if a new target timeline is found, expectedTLEs is
replaced with newExpectedTLEs that is newly allocated by readTimeLineHistory(),
and old expectedTLEs is released using list_free_deep().
However, if the current timeline is not part of the history of the new timeline,
the function returns without using newExpectedTLEs, nor releasing it. I wonder
this is a memory leak and it is better to release it, although the affect may
be not so much.
I've attached the patch.
Regards,
Yugo Nagata
--
Yugo Nagata <nagata@sraoss.co.jp>
Attachments:
Fix_possible_memory_leak_in_rescanLatestTimeLine.patchtext/x-diff; name=Fix_possible_memory_leak_in_rescanLatestTimeLine.patchDownload
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 178491f6f5..ec518d35e8 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -4157,6 +4157,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
(errmsg("new timeline %u is not a child of database system timeline %u",
newtarget,
replayTLI)));
+ list_free_deep(newExpectedTLEs);
return false;
}
@@ -4172,6 +4173,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
newtarget,
replayTLI,
LSN_FORMAT_ARGS(replayLSN))));
+ list_free_deep(newExpectedTLEs);
return false;
}