History

[py] fix reference counting of exception types (thanks @wackou)

Commit 8bfef30 exposed a reference counting error, causing the interpreter to crash before exiting. The solution is to incref the exception type before calling PyErr_Restore.

Paul Brossier committed 7 years ago

Commit 673d7e31 parent 841ceed1 file · +12 −3Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/ext/py-filter.c+12−3
@@ -163,7 +163,10 @@ Py_filter_set_c_weighting (Py_filter * self, PyObject *args) · 162 unmodified lines
163 // change the RuntimeError into ValueError163 // change the RuntimeError into ValueError
164 PyObject *type, *value, *traceback;164 PyObject *type, *value, *traceback;
165 PyErr_Fetch(&type, &value, &traceback);165 PyErr_Fetch(&type, &value, &traceback);
166 PyErr_Restore(PyExc_ValueError, value, traceback);166 Py_XDECREF(type);
167 type = PyExc_ValueError;
168 Py_XINCREF(type);
169 PyErr_Restore(type, value, traceback);
167 }170 }
168 return NULL;171 return NULL;
169 }172 }
@@ -188,7 +191,10 @@ Py_filter_set_a_weighting (Py_filter * self, PyObject *args) · 18 unmodified lines
188 // change the RuntimeError into ValueError191 // change the RuntimeError into ValueError
189 PyObject *type, *value, *traceback;192 PyObject *type, *value, *traceback;
190 PyErr_Fetch(&type, &value, &traceback);193 PyErr_Fetch(&type, &value, &traceback);
191 PyErr_Restore(PyExc_ValueError, value, traceback);194 Py_XDECREF(type);
195 type = PyExc_ValueError;
196 Py_XINCREF(type);
197 PyErr_Restore(type, value, traceback);
192 }198 }
193 return NULL;199 return NULL;
194 }200 }
@@ -213,7 +219,10 @@ Py_filter_set_biquad(Py_filter * self, PyObject *args) · 18 unmodified lines
213 // change the RuntimeError into ValueError219 // change the RuntimeError into ValueError
214 PyObject *type, *value, *traceback;220 PyObject *type, *value, *traceback;
215 PyErr_Fetch(&type, &value, &traceback);221 PyErr_Fetch(&type, &value, &traceback);
216 PyErr_Restore(PyExc_ValueError, value, traceback);222 Py_XDECREF(type);
223 type = PyExc_ValueError;
224 Py_XINCREF(type);
225 PyErr_Restore(type, value, traceback);
217 }226 }
218 return NULL;227 return NULL;
219 }228 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t