mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
Added missing error check to list append in typecast_array_scan
This commit is contained in:
parent
27b26bc210
commit
8bf9299c17
|
@ -186,6 +186,7 @@ typecast_array_scan(const char *str, Py_ssize_t strlength,
|
||||||
state, length, token);
|
state, length, token);
|
||||||
if (state == ASCAN_TOKEN || state == ASCAN_QUOTED) {
|
if (state == ASCAN_TOKEN || state == ASCAN_QUOTED) {
|
||||||
PyObject *obj;
|
PyObject *obj;
|
||||||
|
int result;
|
||||||
if (!quotes && length == 4
|
if (!quotes && length == 4
|
||||||
&& (token[0] == 'n' || token[0] == 'N')
|
&& (token[0] == 'n' || token[0] == 'N')
|
||||||
&& (token[1] == 'u' || token[1] == 'U')
|
&& (token[1] == 'u' || token[1] == 'U')
|
||||||
|
@ -201,17 +202,19 @@ typecast_array_scan(const char *str, Py_ssize_t strlength,
|
||||||
if (state == ASCAN_QUOTED) PyMem_Free(token);
|
if (state == ASCAN_QUOTED) PyMem_Free(token);
|
||||||
if (obj == NULL) return -1;
|
if (obj == NULL) return -1;
|
||||||
|
|
||||||
PyList_Append(array, obj);
|
result = PyList_Append(array, obj);
|
||||||
TO_STATE(obj);
|
|
||||||
Py_CLEAR(obj);
|
Py_CLEAR(obj);
|
||||||
|
if (result < 0) { return -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (state == ASCAN_BEGIN) {
|
else if (state == ASCAN_BEGIN) {
|
||||||
PyObject *sub = PyList_New(0);
|
PyObject *sub;
|
||||||
if (sub == NULL) return -1;
|
int result;
|
||||||
|
if (!(sub = PyList_New(0))) { return -1; }
|
||||||
|
|
||||||
PyList_Append(array, sub);
|
result = PyList_Append(array, sub);
|
||||||
Py_DECREF(sub);
|
Py_DECREF(sub); /* still kept alive by array, if succeeded */
|
||||||
|
if (result < 0) { return -1; }
|
||||||
|
|
||||||
if (stack_index == MAX_DIMENSIONS) {
|
if (stack_index == MAX_DIMENSIONS) {
|
||||||
PyErr_SetString(DataError, "excessive array dimensions");
|
PyErr_SetString(DataError, "excessive array dimensions");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user