The result of PLyUnicode_AsString is already palloc'd,
so pstrdup'ing it is just a waste of time and memory.
More importantly it might confuse people about whether
that's necessary. Doesn't seem important enough to
back-patch, but we should fix it. Spotted by Coverity.
val = PyObject_GetAttrString(obj, attrname);
if (val != NULL && val != Py_None)
{
- *str = pstrdup(PLyUnicode_AsString(val));
+ *str = PLyUnicode_AsString(val);
}
Py_XDECREF(val);
}
return ret;
}
-/* enforce cast of object to string */
+/* enforce cast of object to string (returns a palloc'd string or NULL) */
static char *
object_to_string(PyObject *obj)
{
{
char *str;
- str = pstrdup(PLyUnicode_AsString(so));
+ str = PLyUnicode_AsString(so);
Py_DECREF(so);
return str;