]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36356: pymain_free() calls _PyRuntime_Finalize() (GH-12436)
authorVictor Stinner <vstinner@redhat.com>
Tue, 19 Mar 2019 14:08:17 +0000 (15:08 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Mar 2019 14:08:17 +0000 (15:08 +0100)
Ensure that _PyRuntime_Finalize() is always call. This change fix a
few memory leaks when running "python3 -V".

Include/internal/pystate.h
Modules/main.c

index 721d34fa4c19623af9d931672e71c0cd2a6c7b33..5891339b543482d600c133486c13ebe79bf3e658 100644 (file)
@@ -118,6 +118,9 @@ PyAPI_FUNC(void) _PyRuntimeState_Fini(_PyRuntimeState *);
    Return NULL on success, or return an error message on failure. */
 PyAPI_FUNC(_PyInitError) _PyRuntime_Initialize(void);
 
+PyAPI_FUNC(void) _PyRuntime_Finalize(void);
+
+
 #define _Py_CURRENTLY_FINALIZING(tstate) \
     (_PyRuntime.finalizing == tstate)
 
index a745381109d37775913779c975d81107c135d03f..f94689496a38fca00c7f69566ba16f1eb90a4b3b 100644 (file)
@@ -660,6 +660,8 @@ pymain_free_raw(_PyMain *pymain)
     orig_argc = 0;
     orig_argv = NULL;
 
+    _PyRuntime_Finalize();
+
     PyMem_SetAllocator(PYMEM_DOMAIN_RAW, &old_alloc);
 }