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.
(cherry picked from commit
5854cf38a25ab8b0c6ab0296098166014f77caa3)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
Co-authored-by: Petr Viktorin <encukou@gmail.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;