Mercurial > cpython-lru_cache-weakref
comparison Objects/unicodeobject.c @ 81826:02c4ecc87f74
Issue #16971: Fix a refleak in the charmap decoder.
| author | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| date | Tue, 29 Jan 2013 12:16:57 +0200 |
| parents | 218da678bb8b 625c397a7283 |
| children | eb0370d4686c |
comparison
equal
deleted
inserted
replaced
| 81824:9b25df066f37 | 81826:02c4ecc87f74 |
|---|---|
| 7381 (unsigned long)MAX_UNICODE + 1); | 7381 (unsigned long)MAX_UNICODE + 1); |
| 7382 Py_DECREF(x); | 7382 Py_DECREF(x); |
| 7383 goto onError; | 7383 goto onError; |
| 7384 } | 7384 } |
| 7385 | 7385 |
| 7386 if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) | 7386 if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) { |
| 7387 Py_DECREF(x); | |
| 7387 goto onError; | 7388 goto onError; |
| 7389 } | |
| 7388 PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); | 7390 PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); |
| 7389 writer.pos++; | 7391 writer.pos++; |
| 7390 } | 7392 } |
| 7391 else if (PyUnicode_Check(x)) { | 7393 else if (PyUnicode_Check(x)) { |
| 7392 if (PyUnicode_READY(x) == -1) | 7394 if (PyUnicode_READY(x) == -1) { |
| 7395 Py_DECREF(x); | |
| 7393 goto onError; | 7396 goto onError; |
| 7397 } | |
| 7394 if (PyUnicode_GET_LENGTH(x) == 1) { | 7398 if (PyUnicode_GET_LENGTH(x) == 1) { |
| 7395 Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); | 7399 Py_UCS4 value = PyUnicode_READ_CHAR(x, 0); |
| 7396 if (value == 0xFFFE) | 7400 if (value == 0xFFFE) |
| 7397 goto Undefined; | 7401 goto Undefined; |
| 7398 if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) | 7402 if (_PyUnicodeWriter_Prepare(&writer, 1, value) == -1) { |
| 7403 Py_DECREF(x); | |
| 7399 goto onError; | 7404 goto onError; |
| 7405 } | |
| 7400 PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); | 7406 PyUnicode_WRITE(writer.kind, writer.data, writer.pos, value); |
| 7401 writer.pos++; | 7407 writer.pos++; |
| 7402 } | 7408 } |
| 7403 else { | 7409 else { |
| 7404 writer.overallocate = 1; | 7410 writer.overallocate = 1; |
| 7405 if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) | 7411 if (_PyUnicodeWriter_WriteStr(&writer, x) == -1) { |
| 7412 Py_DECREF(x); | |
| 7406 goto onError; | 7413 goto onError; |
| 7414 } | |
| 7407 } | 7415 } |
| 7408 } | 7416 } |
| 7409 else { | 7417 else { |
| 7410 /* wrong return value */ | 7418 /* wrong return value */ |
| 7411 PyErr_SetString(PyExc_TypeError, | 7419 PyErr_SetString(PyExc_TypeError, |
