pgbackrest.git / summary / log / commit / refs

commit    f4e1adf0591ab06c1ced79cf94a77331de16db52
Author:   David Steele <david@pgbackrest.org>
Date:     Tue May 27 20:33:32 2025 +0000

    Fix issue with calling lstClear() twice.
    
    The list pointer was not nulled out so calling lstClear() caused a double free.
    
    This is not a production issue but was noticed in some upcoming test code.


src/common/type/list.c | 1 + test/src/module/common/typeListTest.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/common/type/list.c b/src/common/type/list.c index 75ad65990..ff2a9b80e 100644 --- a/src/common/type/list.c +++ b/src/common/type/list.c @@ -66,6 +66,7 @@ lstClear(List *const this) } MEM_CONTEXT_END(); + this->pub.list = NULL; this->pub.listSize = 0; this->listSizeMax = 0; } diff --git a/test/src/module/common/typeListTest.c b/test/src/module/common/typeListTest.c index f7564c4a0..64ad22d90 100644 --- a/test/src/module/common/typeListTest.c +++ b/test/src/module/common/typeListTest.c @@ -38,6 +38,7 @@ testRun(void) TEST_RESULT_Z(logBuf, "{size: 1}", "check log"); TEST_RESULT_VOID(lstClear(list), "clear list"); + TEST_RESULT_VOID(lstClear(list), "clear list again to ensure everything was cleared correctly"); TEST_RESULT_VOID(FUNCTION_LOG_OBJECT_FORMAT(list, lstToLog, logBuf, sizeof(logBuf)), "bufToLog"); TEST_RESULT_Z(logBuf, "{size: 0}", "check log"); [parent: b5a26d99a041]