diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 8 | ||||
-rw-r--r-- | Objects/floatobject.c | 2 | ||||
-rw-r--r-- | Objects/longobject.c | 10 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 4 |
4 files changed, 14 insertions, 10 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index e0e3cd0..1cfdbae 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2609,17 +2609,21 @@ bytes_extend(PyBytesObject *self, PyObject *arg) if (! _getbytevalue(item, &value)) { Py_DECREF(item); Py_DECREF(it); + PyMem_Free(buf); return NULL; } buf[len++] = value; Py_DECREF(item); if (len >= buf_size) { + char *new_buf; buf_size = len + (len >> 1) + 1; - buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char)); - if (buf == NULL) { + new_buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char)); + if (new_buf == NULL) { Py_DECREF(it); + PyMem_Free(buf); return PyErr_NoMemory(); } + buf = new_buf; } } Py_DECREF(it); diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 353a21d..20f1510 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1607,7 +1607,7 @@ PyFloat_Fini(void) } else { fprintf(stderr, - ": %" PY_FORMAT_SIZE_T "d unfreed floats%s in %" + ": %" PY_FORMAT_SIZE_T "d unfreed float%s in %" PY_FORMAT_SIZE_T "d out of %" PY_FORMAT_SIZE_T "d block%s\n", fsum, fsum == 1 ? "" : "s", diff --git a/Objects/longobject.c b/Objects/longobject.c index 1d4b502..b8725df 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1620,7 +1620,7 @@ long_from_binary_base(char **str, int base) n >>= 1; /* n <- total # of bits needed, while setting p to end-of-string */ n = 0; - while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base) + while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)] < base) ++p; *str = p; /* n <- # of Python digits needed, = ceiling(n/PyLong_SHIFT). */ @@ -1641,7 +1641,7 @@ long_from_binary_base(char **str, int base) bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - int k = _PyLong_DigitValue[Py_CHARMASK(*p)]; + int k = _PyLong_DigitValue[(unsigned)Py_CHARMASK(*p)]; assert(k >= 0 && k < base); accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; @@ -1828,7 +1828,7 @@ digit beyond the first. /* Find length of the string of numeric characters. */ scan = str; - while (_PyLong_DigitValue[Py_CHARMASK(*scan)] < base) + while (_PyLong_DigitValue[(unsigned)Py_CHARMASK(*scan)] < base) ++scan; /* Create a long object that can contain the largest possible @@ -1854,10 +1854,10 @@ digit beyond the first. /* Work ;-) */ while (str < scan) { /* grab up to convwidth digits from the input string */ - c = (digit)_PyLong_DigitValue[Py_CHARMASK(*str++)]; + c = (digit)_PyLong_DigitValue[(unsigned)Py_CHARMASK(*str++)]; for (i = 1; i < convwidth && str != scan; ++i, ++str) { c = (twodigits)(c * base + - _PyLong_DigitValue[Py_CHARMASK(*str)]); + _PyLong_DigitValue[(unsigned)Py_CHARMASK(*str)]); assert(c < PyLong_BASE); } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 60cbffa..fef304a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -512,13 +512,13 @@ PyObject *PyUnicode_FromStringAndSize(const char *u, Py_ssize_t size) /* Single characters are shared when using this constructor. Restrict to ASCII, since the input must be UTF-8. */ if (size == 1 && Py_CHARMASK(*u) < 128) { - unicode = unicode_latin1[Py_CHARMASK(*u)]; + unicode = unicode_latin1[(unsigned)Py_CHARMASK(*u)]; if (!unicode) { unicode = _PyUnicode_New(1); if (!unicode) return NULL; unicode->str[0] = Py_CHARMASK(*u); - unicode_latin1[Py_CHARMASK(*u)] = unicode; + unicode_latin1[(unsigned)Py_CHARMASK(*u)] = unicode; } Py_INCREF(unicode); return (PyObject *)unicode; |