bpo-30961: Fix decrementing a borrowed reference in tracemalloc. (#27… · python/cpython@cb3f024 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1408,7 +1408,7 @@ _PyTraceMalloc_Init(void)
1408 1408 if (key == NULL)
1409 1409 return -1;
1410 1410
1411 -value = PyDict_GetItemWithError(xoptions, key);
1411 +value = PyDict_GetItemWithError(xoptions, key); /* borrowed */
1412 1412 Py_DECREF(key);
1413 1413 if (value == NULL) {
1414 1414 if (PyErr_Occurred())
@@ -1419,7 +1419,6 @@ _PyTraceMalloc_Init(void)
1419 1419 }
1420 1420
1421 1421 nframe = parse_sys_xoptions(value);
1422 -Py_DECREF(value);
1423 1422 if (nframe < 0) {
1424 1423 Py_FatalError("-X tracemalloc=NFRAME: invalid number of frames");
1425 1424 }