summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_lsprof.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 9bc7f61375..3e75f2218b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -100,6 +100,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 #7250: Fix info leak of os.environ across multi-run uses of
wsgiref.handlers.CGIHandler.
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 43cb9b1242..a4951c033b 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