PyObject *ret = NULL;
cli_credentials_get_ntlm_username_domain(PyCredentials_AsCliCredentials(self),
frame, &user, &domain);
- ret = Py_BuildValue("(OO)",
- PyString_FromStringOrNULL(user),
- PyString_FromStringOrNULL(domain));
+ ret = Py_BuildValue("(ss)",
+ user,
+ domain);
+
TALLOC_FREE(frame);
return ret;
}
Py_RETURN_NONE;
} else {
/* We don't want this attached to the 'ldb' any more */
- return Py_BuildValue(discard_const_p(char, "(iO)"),
- ldif->changetype,
- PyLdbMessage_FromMessage(ldif->msg));
+ PyObject *obj = PyLdbMessage_FromMessage(ldif->msg);
+ PyObject *result =
+ Py_BuildValue(discard_const_p(char, "(iO)"),
+ ldif->changetype,
+ obj);
+ Py_CLEAR(obj);
+ return result;
}
}
Py_ssize_t i, j = 0;
PyObject *l = PyList_New(msg->num_elements + (msg->dn == NULL?0:1));
if (msg->dn != NULL) {
- PyList_SetItem(l, 0, Py_BuildValue("(sO)", "dn", pyldb_Dn_FromDn(msg->dn)));
+ PyObject *obj = pyldb_Dn_FromDn(msg->dn);
+ PyList_SetItem(l, 0, Py_BuildValue("(sO)", "dn", obj));
+ Py_CLEAR(obj);
j++;
}
for (i = 0; i < msg->num_elements; i++, j++) {
PyObject *py_el = PyLdbMessageElement_FromMessageElement(&msg->elements[i], msg->elements);
PyObject *value = Py_BuildValue("(sO)", msg->elements[i].name, py_el);
+ Py_CLEAR(py_el);
PyList_SetItem(l, j, value);
}
return l;
{
PyObject *result = (PyObject *)state;
PyObject *file = NULL;
+ PyObject *size = NULL;
int ret;
/* suppress '.' and '..' in the results we return */
if (ISDOT(finfo->name) || ISDOTDOT(finfo->name)) {
return NT_STATUS_OK;
}
-
+ size = PyLong_FromUnsignedLongLong(finfo->size);
/*
* Build a dictionary representing the file info.
* Note: Windows does not always return short_name (so it may be None)
"name", finfo->name,
"attrib", (int)finfo->mode,
"short_name", finfo->short_name,
- "size", PyLong_FromUnsignedLongLong(finfo->size),
+ "size", size,
"mtime",
convert_timespec_to_time_t(finfo->mtime_ts));
+ Py_CLEAR(size);
+
if (file == NULL) {
return NT_STATUS_NO_MEMORY;
}
struct ldb_context *samdb;
PyObject *py_ldb, *ret, *pydn;
PyObject *py_dns_partition = NULL;
+ PyObject *result = NULL;
char *dns_name;
TALLOC_CTX *frame;
NTSTATUS status;
ret = py_dnsp_DnssrvRpcRecord_get_list(records, num_records);
pydn = pyldb_Dn_FromDn(dn);
talloc_free(frame);
- return Py_BuildValue("(OO)", pydn, ret);
+ result = Py_BuildValue("(OO)", pydn, ret);
+ Py_CLEAR(ret);
+ Py_CLEAR(pydn);
+ return result;
}
static PyObject *py_dsdb_dns_extract(PyObject *self, PyObject *args)