1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-26 01:49:31 +03:00

pyldb: check for errors in PyLdb_GetPyType()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
Douglas Bagnall
2018-05-03 11:17:55 +12:00
committed by Douglas Bagnall
parent e075f52a75
commit 339f8bbdda
2 changed files with 21 additions and 5 deletions

View File

@ -34,7 +34,8 @@ static PyObject *ldb_module = NULL;
*/
static PyTypeObject * PyLdb_GetPyType(const char *typename)
{
PyObject *py_obj = NULL;
PyTypeObject *type = NULL;
bool ok;
if (ldb_module == NULL) {
ldb_module = PyImport_ImportModule("ldb");
@ -43,9 +44,26 @@ static PyTypeObject * PyLdb_GetPyType(const char *typename)
}
}
py_obj = PyObject_GetAttrString(ldb_module, typename);
type = (PyTypeObject *)PyObject_GetAttrString(ldb_module, typename);
return (PyTypeObject*)py_obj;
if (type == NULL) {
PyErr_Format(PyExc_NameError,
"Unable to find type %s in ldb module",
typename);
return NULL;
}
ok = PyType_Check(type);
if (! ok) {
PyErr_Format(PyExc_TypeError,
"Expected type ldb.%s, not %s",
typename, Py_TYPE(type)->tp_name);
Py_DECREF(type);
return NULL;
}
return type;
}
bool pyldb_check_type(PyObject *obj, const char *typename)

View File

@ -1,6 +1,4 @@
samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_auth_user_session
samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_encrypt_netr_crypt_password
samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_hive_open_ldb
samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_net_replicate_chunk_1
samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_net_replicate_init__1
samba.tests.segfault.samba.tests.segfault.SegfaultTests.test_net_replicate_init__3