python: fix FaultError reference leak

PyErr_SetObject() takes a reference on the exception value, so we need
to drop the reference we got when we created the value. Issue #196 ran
into this by reading tons of unmapped addresses.

Fixes: 80fef04c70 ("Add address attribute to FaultError exception")
Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
Omar Sandoval 2022-08-16 17:35:36 -07:00
parent 79ea6589c2
commit 6c90315f6f

View File

@ -161,8 +161,10 @@ DRGNPY_PUBLIC void *set_drgn_error(struct drgn_error *err)
exc = PyObject_CallFunction((PyObject *)&FaultError_type, "sK",
err->message, err->address);
if (exc)
if (exc) {
PyErr_SetObject((PyObject *)&FaultError_type, exc);
Py_DECREF(exc);
}
break;
}
case DRGN_ERROR_TYPE: