mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 03:26:37 +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 '{'");
|
||||
return NULL;
|
||||
}
|
||||
if (str[1] == '\0') {
|
||||
PyErr_SetString(DataError, "malformed array: '{'");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Dprintf("typecast_GENERIC_ARRAY_cast: str = '%s',"
|
||||
" len = " FORMAT_CODE_PY_SSIZE_T, str, len);
|
||||
|
|
|
@ -202,7 +202,7 @@ class TypesBasicTests(unittest.TestCase):
|
|||
|
||||
def testArrayMalformed(self):
|
||||
curs = self.conn.cursor()
|
||||
ss = ['', '{}}', '{' * 20 + '}' * 20]
|
||||
ss = ['', '{', '{}}', '{' * 20 + '}' * 20]
|
||||
for s in ss:
|
||||
self.assertRaises(psycopg2.DataError,
|
||||
psycopg2.extensions.STRINGARRAY, b(s), curs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user