diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-28 21:53:49 +0200 | 
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-09-28 21:53:49 +0200 | 
| commit | fd85c3aa8dbbdd3193a41b73ad591d03a1258358 (patch) | |
| tree | 99e4909a1607afa05e46c83c02a67ed33ab66d5b /Python/formatter_unicode.c | |
| parent | dba2deeca2c070e2dfa08649b5729208567fd414 (diff) | |
| download | cpython-git-fd85c3aa8dbbdd3193a41b73ad591d03a1258358.tar.gz | |
fill_number() and format_string_internal() check for PyUnicode_CopyCharacters() failure
Diffstat (limited to 'Python/formatter_unicode.c')
| -rw-r--r-- | Python/formatter_unicode.c | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index 52ccafa8d0..609df648b0 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -566,7 +566,10 @@ fill_number(PyObject *out, Py_ssize_t pos, const NumberFieldWidths *spec,          PyUnicode_WRITE(kind, data, pos++, spec->sign);      }      if (spec->n_prefix) { -        PyUnicode_CopyCharacters(out, pos, prefix, p_start, spec->n_prefix); +        if (PyUnicode_CopyCharacters(out, pos, +                                     prefix, p_start, +                                     spec->n_prefix) < 0) +            return -1;          if (toupper) {              Py_ssize_t t;              /* XXX if the upper-case prefix is wider than the target @@ -632,7 +635,8 @@ fill_number(PyObject *out, Py_ssize_t pos, const NumberFieldWidths *spec,      }      if (spec->n_remainder) { -        PyUnicode_CopyCharacters(out, pos, digits, d_pos, spec->n_remainder); +        if (PyUnicode_CopyCharacters(out, pos, digits, d_pos, spec->n_remainder) < 0) +            return -1;          pos += spec->n_remainder;          d_pos += spec->n_remainder;      } @@ -735,7 +739,8 @@ format_string_internal(PyObject *value, const InternalFormatSpec *format)                         lpad, rpad);      /* Then the source string. */ -    PyUnicode_CopyCharacters(result, pos, value, 0, len); +    if (PyUnicode_CopyCharacters(result, pos, value, 0, len) < 0) +        Py_CLEAR(result);  done:      return result; | 
