From 4e8081e0c48ccbea6e54d13658bc34b5b545488d Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Wed, 19 Jul 2017 00:33:29 +0800 Subject: [PATCH] bpo-30961: Fix decrementing a borrowed reference in tracemalloc. (#2747) --- .../next/Library/2017-07-18-23-47-51.bpo-30961.064jz0.rst | 1 + Modules/_tracemalloc.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2017-07-18-23-47-51.bpo-30961.064jz0.rst 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 index 000000000000000..b89c6d4769dab9d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2017-07-18-23-47-51.bpo-30961.064jz0.rst @@ -0,0 +1 @@ +Fix decrementing a borrowed reference in tracemalloc. diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index ec8bd960a7f7e02..0ce38ffc78c53f0 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -1731,7 +1731,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()) @@ -1742,7 +1742,6 @@ _PyTraceMalloc_Init(void) } nframe = parse_sys_xoptions(value); - Py_DECREF(value); if (nframe < 0) { Py_FatalError("-X tracemalloc=NFRAME: invalid number of frames"); }