From: Victor Stinner Date: Thu, 4 Mar 2010 00:10:12 +0000 (+0000) Subject: Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler, X-Git-Tag: v2.7a4~43 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56a5153e21666792c6487fc98ce100fe6c51ebb3;p=python Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler, reset also the pointer to the current pointer context. --- diff --git a/Misc/NEWS b/Misc/NEWS index cfdd364096..fb45e5a59c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -41,6 +41,9 @@ Core and Builtins Library ------- +- Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler, + reset also the pointer to the current pointer context. + - Issue #7232: Add support for the context manager protocol to the TarFile class. diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 14bb8f93e8..8820fcf5ad 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -303,12 +303,17 @@ static void clearEntries(ProfilerObject *pObj) { RotatingTree_Enum(pObj->profilerEntries, freeEntry, NULL); pObj->profilerEntries = EMPTY_ROTATING_TREE; - /* release the memory hold by the free list of ProfilerContexts */ + /* release the memory hold by the ProfilerContexts */ + if (pObj->currentProfilerContext) { + free(pObj->currentProfilerContext); + pObj->currentProfilerContext = NULL; + } while (pObj->freelistProfilerContext) { ProfilerContext *c = pObj->freelistProfilerContext; pObj->freelistProfilerContext = c->previous; free(c); } + pObj->freelistProfilerContext = NULL; } static void