diff options
author | Guido van Rossum <guido@python.org> | 1998-06-22 03:54:46 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-06-22 03:54:46 (GMT) |
commit | e67629774fd0b921d886f4f81f83c0368143efdd (patch) | |
tree | e03f65c21da35edfbe4e79dbc9a67b7c513775ce /Objects | |
parent | 3b2b34790ff86abcf87cfcfe061fd9fa8cb0ab32 (diff) | |
download | cpython-e67629774fd0b921d886f4f81f83c0368143efdd.zip cpython-e67629774fd0b921d886f4f81f83c0368143efdd.tar.gz cpython-e67629774fd0b921d886f4f81f83c0368143efdd.tar.bz2 |
Add check in long-to-int conversion for at least one digit.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/longobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 9657c08..d638c64 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -453,6 +453,7 @@ PyLong_FromString(str, pend, base) int base; { int sign = 1; + char *start; PyLongObject *z; if ((base != 0 && base < 2) || base > 36) { @@ -481,6 +482,7 @@ PyLong_FromString(str, pend, base) if (base == 16 && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) str += 2; z = _PyLong_New(0); + start = str; for ( ; z != NULL; ++str) { int k = -1; PyLongObject *temp; @@ -497,6 +499,11 @@ PyLong_FromString(str, pend, base) Py_DECREF(z); z = temp; } + if (str == start) { + PyErr_SetString(PyExc_ValueError, + "no digits in long int constant"); + return NULL; + } if (sign < 0 && z != NULL && z->ob_size != 0) z->ob_size = -(z->ob_size); if (pend) |