[Python-checkins] r78641 - in python/trunk: Misc/NEWS Modules/_lsprof.c

victor.stinner python-checkins at python.org
Thu Mar 4 01:10:13 CET 2010


Author: victor.stinner
Date: Thu Mar  4 01:10:12 2010
New Revision: 78641

Log:
Issue #7494: fix a crash in _lsprof (cProfile) after clearing the profiler,
reset also the pointer to the current pointer context.


Modified:
   python/trunk/Misc/NEWS
   python/trunk/Modules/_lsprof.c

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Thu Mar  4 01:10:12 2010
@@ -41,6 +41,9 @@
 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.
 

Modified: python/trunk/Modules/_lsprof.c
==============================================================================
--- python/trunk/Modules/_lsprof.c	(original)
+++ python/trunk/Modules/_lsprof.c	Thu Mar  4 01:10:12 2010
@@ -303,12 +303,17 @@
 {
 	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


More information about the Python-checkins mailing list