]> granicus.if.org Git - python/commitdiff
Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler,
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 4 Mar 2010 00:10:12 +0000 (00:10 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 4 Mar 2010 00:10:12 +0000 (00:10 +0000)
reset also the pointer to the current pointer context.

Misc/NEWS
Modules/_lsprof.c

index cfdd364096eb7f050bdecbf478b72402b992977c..fb45e5a59c4ea50e1d6074b9d5013bd5f287aebe 100644 (file)
--- 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.
 
index 14bb8f93e84df254bfd6f1932b88a65ae62169fb..8820fcf5ad4384c889b388f538cb906b1b37fe6f 100644 (file)
@@ -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