mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 17:34:08 +03:00
Fixed infinite loop when parsing '{' as array
This commit is contained in:
parent
72e9cf7b6d
commit
c7bee92160
|
@ -260,6 +260,10 @@ typecast_GENERIC_ARRAY_cast(const char *str, Py_ssize_t len, PyObject *curs)
|
||||||
PyErr_SetString(DataError, "array does not start with '{'");
|
PyErr_SetString(DataError, "array does not start with '{'");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (str[1] == '\0') {
|
||||||
|
PyErr_SetString(DataError, "malformed array: '{'");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Dprintf("typecast_GENERIC_ARRAY_cast: str = '%s',"
|
Dprintf("typecast_GENERIC_ARRAY_cast: str = '%s',"
|
||||||
" len = " FORMAT_CODE_PY_SSIZE_T, str, len);
|
" len = " FORMAT_CODE_PY_SSIZE_T, str, len);
|
||||||
|
|
|
@ -202,7 +202,7 @@ class TypesBasicTests(unittest.TestCase):
|
||||||
|
|
||||||
def testArrayMalformed(self):
|
def testArrayMalformed(self):
|
||||||
curs = self.conn.cursor()
|
curs = self.conn.cursor()
|
||||||
ss = ['', '{}}', '{' * 20 + '}' * 20]
|
ss = ['', '{', '{}}', '{' * 20 + '}' * 20]
|
||||||
for s in ss:
|
for s in ss:
|
||||||
self.assertRaises(psycopg2.DataError,
|
self.assertRaises(psycopg2.DataError,
|
||||||
psycopg2.extensions.STRINGARRAY, b(s), curs)
|
psycopg2.extensions.STRINGARRAY, b(s), curs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user