On some macOS versions there was an off-by-one error in wcsxfrm() which
caused writing past the end of the array if its size was not calculated
by running wcsxfrm() first.
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
--- /dev/null
+Fix possible crash in :func:`locale.strxfrm` due to a platform bug on
+macOS.
/* assume no change in size, first */
n1 = n1 + 1;
- buf = PyMem_New(wchar_t, n1);
+ /* Yet another +1 is needed to work around a platform bug in wcsxfrm()
+ * on macOS. See gh-130567. */
+ buf = PyMem_New(wchar_t, n1+1);
if (!buf) {
PyErr_NoMemory();
goto exit;