[Python-checkins] r55156 - python/branches/py3k-struni/Objects/unicodeobject.c
walter.doerwald
python-checkins at python.org
Sun May 6 12:00:03 CEST 2007
Author: walter.doerwald
Date: Sun May 6 12:00:02 2007
New Revision: 55156
Modified:
python/branches/py3k-struni/Objects/unicodeobject.c
Log:
Check whether the strlen() result overflows Py_ssize_t.
Modified: python/branches/py3k-struni/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/unicodeobject.c (original)
+++ python/branches/py3k-struni/Objects/unicodeobject.c Sun May 6 12:00:02 2007
@@ -396,7 +396,11 @@
PyObject *PyUnicode_FromString(const char *u)
{
PyUnicodeObject *unicode;
- Py_ssize_t size = strlen(u);
+ size_t size = strlen(u);
+ if (size > PY_SSIZE_T_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "input too long");
+ return NULL;
+ }
/* If the Unicode data is known at construction time, we can apply
some optimizations which share commonly used objects. */
More information about the Python-checkins
mailing list