diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-06-23-00-25-53.gh-issue-94149.e0Q1dg.rst b/Misc/NEWS.d/next/Core and Builtins/2022-06-23-00-25-53.gh-issue-94149.e0Q1dg.rst new file mode 100644 index 000000000000000..57eae83227002ae --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-06-23-00-25-53.gh-issue-94149.e0Q1dg.rst @@ -0,0 +1 @@ +Fixed an unaligned write in convertsimple() which could crash on architectures requiring strict alignment, e.g. sparc. diff --git a/Python/getargs.c b/Python/getargs.c index fb4a5124beab8a6..f3aef2e839392f5 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -919,7 +919,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, if (*format == '#') { REQUIRE_PY_SSIZE_T_CLEAN; Py_ssize_t *psize = va_arg(*p_va, Py_ssize_t*); - *psize = count; + memcpy(psize, &count, sizeof(Py_ssize_t)); format++; } else { if (strlen(*p) != (size_t)count) {