Core and builtins
-----------------
+- Fixed a bug in the cache of length-one Unicode strings that could
+ lead to a seg fault. The specific problem occurred when an earlier,
+ non-fatal error left an uninitialized Unicode object in the
+ freelist.
+
- The % formatting operator now supports '%F' which is equivalent to
'%f'. This has always been documented but never implemented.
instead ! */
if (unicode == unicode_empty ||
(unicode->length == 1 &&
- unicode->str[0] < 256 &&
+ /* XXX Is unicode->str[] always unsigned? */
+ unicode->str[0] < 256U &&
unicode_latin1[unicode->str[0]] == unicode)) {
PyErr_SetString(PyExc_SystemError,
"can't resize shared unicode objects");
PyErr_NoMemory();
goto onError;
}
+ /* Initialize the first element to guard against cases where
+ the caller fails before initializing str.
+ */
+ unicode->str[0] = 0;
unicode->str[length] = 0;
unicode->length = length;
unicode->hash = -1;
else {
startinpos = s-starts;
endinpos = startinpos + 1;
- outpos = p-PyUnicode_AS_UNICODE(v);
+ outpos = p - (Py_UNICODE *)PyUnicode_AS_UNICODE(v);
if (unicode_decode_call_errorhandler(
errors, &errorHandler,
"ascii", "ordinal not in range(128)",