mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 17:34:08 +03:00
Dropped possible wrong code path in conn_decode
It shouldn't happen for both cdecoder and pydecoder to be null, but just in case...
This commit is contained in:
parent
117f7d33f8
commit
5b28d7b9c9
|
@ -121,10 +121,6 @@ exit:
|
||||||
PyObject *
|
PyObject *
|
||||||
conn_decode(connectionObject *self, const char *str, Py_ssize_t len)
|
conn_decode(connectionObject *self, const char *str, Py_ssize_t len)
|
||||||
{
|
{
|
||||||
PyObject *b = NULL;
|
|
||||||
PyObject *t = NULL;
|
|
||||||
PyObject *rv = NULL;
|
|
||||||
|
|
||||||
if (len < 0) { len = strlen(str); }
|
if (len < 0) { len = strlen(str); }
|
||||||
|
|
||||||
if (self) {
|
if (self) {
|
||||||
|
@ -132,22 +128,28 @@ conn_decode(connectionObject *self, const char *str, Py_ssize_t len)
|
||||||
return self->cdecoder(str, len, NULL);
|
return self->cdecoder(str, len, NULL);
|
||||||
}
|
}
|
||||||
else if (self->pydecoder) {
|
else if (self->pydecoder) {
|
||||||
if (!(b = Bytes_FromStringAndSize(str, len))) { goto exit; }
|
PyObject *b = NULL;
|
||||||
|
PyObject *t = NULL;
|
||||||
|
PyObject *rv = NULL;
|
||||||
|
|
||||||
|
if (!(b = Bytes_FromStringAndSize(str, len))) { goto error; }
|
||||||
if (!(t = PyObject_CallFunctionObjArgs(self->pydecoder, b, NULL))) {
|
if (!(t = PyObject_CallFunctionObjArgs(self->pydecoder, b, NULL))) {
|
||||||
goto exit;
|
goto error;
|
||||||
}
|
}
|
||||||
rv = PyTuple_GetItem(t, 0);
|
if (!(rv = PyTuple_GetItem(t, 0))) { goto error; }
|
||||||
Py_XINCREF(rv);
|
Py_INCREF(rv); /* PyTuple_GetItem gives a borrowes one */
|
||||||
|
error:
|
||||||
|
Py_XDECREF(t);
|
||||||
|
Py_XDECREF(b);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return PyUnicode_FromStringAndSize(str, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return PyUnicode_FromStringAndSize(str, len);
|
return PyUnicode_FromStringAndSize(str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
|
||||||
Py_XDECREF(t);
|
|
||||||
Py_XDECREF(b);
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* conn_notice_callback - process notices */
|
/* conn_notice_callback - process notices */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user