diff options
| author | Georg Brandl <georg@python.org> | 2012-09-29 07:27:15 (GMT) |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2012-09-29 07:27:15 (GMT) |
| commit | 99a247fd01c1cd780c0c3ee1116657627f1ee744 (patch) | |
| tree | 319e33cb6612c3fafb2eb82e15c5e85e3d771e4f /Objects/longobject.c | |
| parent | 1628eaa5dc8892ff381ca7558cc7c8d80fac494d (diff) | |
| parent | 8ed677db129171317b8ee7cd45b39b9013f5a2d6 (diff) | |
| download | cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.zip cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.tar.gz cpython-99a247fd01c1cd780c0c3ee1116657627f1ee744.tar.bz2 | |
Merge with main repo default branch.
Diffstat (limited to 'Objects/longobject.c')
| -rw-r--r-- | Objects/longobject.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index 80fe724..73413dd 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -30,7 +30,7 @@ */ static PyLongObject small_ints[NSMALLNEGINTS + NSMALLPOSINTS]; #ifdef COUNT_ALLOCS -int quick_int_allocs, quick_neg_int_allocs; +Py_ssize_t quick_int_allocs, quick_neg_int_allocs; #endif static PyObject * @@ -1628,8 +1628,10 @@ long_to_decimal_string_internal(PyObject *aa, strlen++; } if (writer) { - if (_PyUnicodeWriter_Prepare(writer, strlen, '9') == -1) + if (_PyUnicodeWriter_Prepare(writer, strlen, '9') == -1) { + Py_DECREF(scratch); return -1; + } kind = writer->kind; str = NULL; } @@ -4283,8 +4285,8 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds) string = PyByteArray_AS_STRING(x); else string = PyBytes_AS_STRING(x); - if (strlen(string) != (size_t)size) { - /* We only see this if there's a null byte in x, + if (strlen(string) != (size_t)size || !size) { + /* We only see this if there's a null byte in x or x is empty, x is a bytes or buffer, *and* a base is given. */ PyErr_Format(PyExc_ValueError, "invalid literal for int() with base %d: %R", |
