Skip to content

Commit bf4d84b

Browse files
committed
Fix reference leak in _lprof.c
1 parent 6acaf65 commit bf4d84b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/_lsprof.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ PyObject* get_cfunc_from_callable(PyObject* callable, PyObject* self_arg, PyObje
702702
if (PyCFunction_Check(meth)) {
703703
return (PyObject*)((PyCFunctionObject *)meth);
704704
}
705+
Py_DECREF(meth);
705706
}
706707
return NULL;
707708
}
@@ -961,6 +962,8 @@ profiler_traverse(PyObject *op, visitproc visit, void *arg)
961962
ProfilerObject *self = ProfilerObject_CAST(op);
962963
Py_VISIT(Py_TYPE(op));
963964
Py_VISIT(self->externalTimer);
965+
Py_VISIT(self->missing);
966+
964967
return 0;
965968
}
966969

@@ -979,6 +982,7 @@ profiler_dealloc(PyObject *op)
979982

980983
flush_unmatched(self);
981984
clearEntries(self);
985+
Py_XDECREF(self->missing);
982986
Py_XDECREF(self->externalTimer);
983987
PyTypeObject *tp = Py_TYPE(self);
984988
tp->tp_free(self);
@@ -1017,7 +1021,7 @@ profiler_init_impl(ProfilerObject *self, PyObject *timer, double timeunit,
10171021
if (!monitoring) {
10181022
return -1;
10191023
}
1020-
self->missing = PyObject_GetAttrString(monitoring, "MISSING");
1024+
Py_XSETREF(self->missing, PyObject_GetAttrString(monitoring, "MISSING"));
10211025
if (!self->missing) {
10221026
Py_DECREF(monitoring);
10231027
return -1;

0 commit comments

Comments
 (0)