1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-10-30 23:37:45 +02:00

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.
This commit is contained in:
David Steele
2025-05-27 16:33:32 -04:00
parent b5a26d99a0
commit f4e1adf059
2 changed files with 2 additions and 0 deletions

View File

@@ -66,6 +66,7 @@ lstClear(List *const this)
}
MEM_CONTEXT_END();
this->pub.list = NULL;
this->pub.listSize = 0;
this->listSizeMax = 0;
}

View File

@@ -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");