]> granicus.if.org Git - python/commitdiff
bpo-30961: Fix decrementing a borrowed reference in tracemalloc. (#2747) (#2749)
authorXiang Zhang <angwerzx@126.com>
Tue, 18 Jul 2017 16:51:58 +0000 (00:51 +0800)
committerGitHub <noreply@github.com>
Tue, 18 Jul 2017 16:51:58 +0000 (00:51 +0800)
(cherry picked from commit 4ed5ad79ec6c6270e6018bd0a55656305ee60907)

Misc/NEWS.d/next/Library/2017-07-18-23-47-51.bpo-30961.064jz0.rst [new file with mode: 0644]
Modules/_tracemalloc.c

diff --git a/Misc/NEWS.d/next/Library/2017-07-18-23-47-51.bpo-30961.064jz0.rst b/Misc/NEWS.d/next/Library/2017-07-18-23-47-51.bpo-30961.064jz0.rst
new file mode 100644 (file)
index 0000000..b89c6d4
--- /dev/null
@@ -0,0 +1 @@
+Fix decrementing a borrowed reference in tracemalloc.
index 65bf7a33d946ff6e83f5820ad33e6e7654a30d23..a923e798c12a726850705e4b808c5dd95f3f894b 100644 (file)
@@ -1408,7 +1408,7 @@ _PyTraceMalloc_Init(void)
         if (key == NULL)
             return -1;
 
-        value = PyDict_GetItemWithError(xoptions, key);
+        value = PyDict_GetItemWithError(xoptions, key); /* borrowed */
         Py_DECREF(key);
         if (value == NULL) {
             if (PyErr_Occurred())
@@ -1419,7 +1419,6 @@ _PyTraceMalloc_Init(void)
         }
 
         nframe = parse_sys_xoptions(value);
-        Py_DECREF(value);
         if (nframe < 0) {
             Py_FatalError("-X tracemalloc=NFRAME: invalid number of frames");
         }