for (i = 0; i < PyList_Size (attributes); ++i)
{
PyObject *tuple, *pyvalue;
+ PyObject *s = NULL;
char *attr, *value;
char *escaped;
return -1;
if (PyUnicode_Check(pyvalue)) {
- PyObject *s = PyUnicode_AsUTF8String(pyvalue);
+ s = PyUnicode_AsUTF8String(pyvalue);
if (!s) {
return -1;
}
value = PyString_AsString(s);
- Py_DECREF(s);
} else if (PyString_Check(pyvalue)) {
value = PyString_AsString(pyvalue);
} else {
escaped = g_markup_escape_text (value, -1);
attr_length += 2 + strlen(attr) + strlen(escaped) + 2;
g_free(escaped);
+ Py_XDECREF(s);
}
return attr_length + indent + self_indent;
for (i = 0; i < PyList_Size (attributes); ++i)
{
PyObject *tuple, *pyvalue;
+ PyObject *s = NULL;
char *attr, *value, *escaped;
tuple = PyList_GetItem (attributes, i);
goto out;
if (PyUnicode_Check(pyvalue)) {
- PyObject *s = PyUnicode_AsUTF8String(pyvalue);
+ s = PyUnicode_AsUTF8String(pyvalue);
if (!s)
goto out;
value = PyString_AsString(s);
- Py_DECREF(s);
} else if (PyString_Check(pyvalue)) {
value = PyString_AsString(pyvalue);
} else {
g_string_append_c (attr_value, '\"');
if (first)
first = FALSE;
+ Py_XDECREF(s);
}
result = PyUnicode_DecodeUTF8 (attr_value->str, attr_value->len, "strict");