diff --git a/doc/xml/release.xml b/doc/xml/release.xml index 437ac067a..ddc4d9d1f 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -100,7 +100,10 @@ - + + + + diff --git a/src/common/memContext.c b/src/common/memContext.c index ddac5ffee..a9244e3ed 100644 --- a/src/common/memContext.c +++ b/src/common/memContext.c @@ -1064,7 +1064,7 @@ memContextClean(const unsigned int tryDepth, const bool fatal) // mask the original error. if (memContextStack[memContextMaxStackIdx].type == memContextStackTypeNew) { - if (!fatal) // {uncovered !!!} + if (!fatal) memContextFree(memContextStack[memContextMaxStackIdx].memContext); } // Else find the prior context and make it the current context diff --git a/test/src/module/common/memContextTest.c b/test/src/module/common/memContextTest.c index 08f4981fb..ec0fb5918 100644 --- a/test/src/module/common/memContextTest.c +++ b/test/src/module/common/memContextTest.c @@ -426,6 +426,31 @@ testRun(void) TEST_RESULT_BOOL(catch, true, "new context error was caught"); TEST_RESULT_PTR(memContextCurrent(), memContextTop(), "context is now 'TOP'"); + + // ------------------------------------------------------------------------------------------------------------------------ + TEST_TITLE("new context not freed on fatal error"); + + MemContext *volatile memContextFatal; + catch = false; + + TRY_BEGIN() + { + MEM_CONTEXT_NEW_BEGIN(test-new-failed-fatal-block, .childQty = MEM_CONTEXT_QTY_MAX, .allocQty = MEM_CONTEXT_QTY_MAX) + { + memContextFatal = MEM_CONTEXT_NEW(); + THROW(AssertError, "create failed"); + } + MEM_CONTEXT_NEW_END(); + } + CATCH_FATAL() + { + catch = true; + } + TRY_END(); + + TEST_RESULT_VOID(memContextFree(memContextFatal), "free new context not freed by catch fatal"); + TEST_RESULT_BOOL(catch, true, "new context error was caught"); + TEST_RESULT_PTR(memContextCurrent(), memContextTop(), "context is now 'TOP'"); } // *****************************************************************************************************************************