From efe5ddd4173254b1822371c91d57540c6140524a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 13 Dec 2009 12:46:45 +0100 Subject: [PATCH] _lsprof (cProfile): Profiler.clear() keeps references to detroyed nodes clearEntries() delete all nodes of the profiler tree, but currentProfilerContext keeps a reference to a tree node (currentProfilerContext->previous->header attribute). The patch fixes clearEntries() to delete all references (destroy currentProfilerContext and set it to NULL). --- Modules/_lsprof.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 14bb8f9..8820fcf 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 -- 1.6.0.4