Python None objects are handled just like all the other objects with respect to their reference counting. Before returning Py_None, its reference count thus needs to be bumped.
Showing the changes to tools/perf/util/python.c (1 of 1 file). Show all
Unified · Split
| @@ -1004,8 +1004,10 @@ static PyObject *pyrf_evlist__read_on_cpu(struct pyrf_evlist *pevlist, · 1003 unmodified lines | |||
| 1004 | return PyErr_NoMemory(); | 1004 | return PyErr_NoMemory(); |
| 1005 | 1005 | ||
| 1006 | evsel = perf_evlist__event2evsel(evlist, event); | 1006 | evsel = perf_evlist__event2evsel(evlist, event); |
| 1007 | if (!evsel) | 1007 | if (!evsel) { |
| 1008 | Py_INCREF(Py_None); | ||
| 1008 | return Py_None; | 1009 | return Py_None; |
| 1010 | } | ||
| 1009 | 1011 | ||
| 1010 | pevent->evsel = evsel; | 1012 | pevent->evsel = evsel; |
| 1011 | 1013 | ||