* Add reference count to type.
* Add error checking.
* Remove unnecessary tp_new method.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13822
Signed-off-by: Kristján Valur Jónsson <kristjan@rvx.is>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Py_TYPE(self)->tp_free((PyObject*)self);
}
Py_TYPE(self)->tp_free((PyObject*)self);
}
-static PyObject* py_ads_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- ADS *self;
- self = (ADS*)type->tp_alloc(type, 0);
- return (PyObject*)self;
-}
-
static PyObject* py_ads_connect(ADS *self);
static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds)
{
static PyObject* py_ads_connect(ADS *self);
static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds)
{
.tp_doc = "ADS struct",
.tp_methods = ADS_methods,
.tp_init = (initproc)py_ads_init,
.tp_doc = "ADS struct",
.tp_methods = ADS_methods,
.tp_init = (initproc)py_ads_init,
};
static PyMethodDef py_gpo_methods[] = {
};
static PyMethodDef py_gpo_methods[] = {
/* Instantiate the types */
m = PyModule_Create(&moduledef);
if (m == NULL) {
/* Instantiate the types */
m = PyModule_Create(&moduledef);
if (m == NULL) {
- PyModule_AddObject(m, "version",
- PyStr_FromString(SAMBA_VERSION_STRING));
+ if (PyModule_AddObject(m, "version",
+ PyStr_FromString(SAMBA_VERSION_STRING)) ) {
+ goto err;
+ }
+ ads_ADSType.tp_new = PyType_GenericNew;
if (PyType_Ready(&ads_ADSType) < 0) {
if (PyType_Ready(&ads_ADSType) < 0) {
- PyModule_AddObject(m, "ADS_STRUCT", (PyObject *)&ads_ADSType);
+ Py_INCREF(&ads_ADSType);
+ if (PyModule_AddObject(m, "ADS_STRUCT", (PyObject *)&ads_ADSType)) {
+ goto err;
+ }
if (pytalloc_BaseObject_PyType_Ready(&GPOType) < 0) {
if (pytalloc_BaseObject_PyType_Ready(&GPOType) < 0) {
}
Py_INCREF((PyObject *)(void *)&GPOType);
}
Py_INCREF((PyObject *)(void *)&GPOType);
- PyModule_AddObject(m, "GROUP_POLICY_OBJECT",
- (PyObject *)&GPOType);
+ if (PyModule_AddObject(m, "GROUP_POLICY_OBJECT",
+ (PyObject *)&GPOType)) {
+ goto err;
+ }
+err:
+ Py_CLEAR(m);
+ return NULL;