Skip to content

gh-151284: Fix test_capi on UBSan#151286

Open
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:test_capi
Open

gh-151284: Fix test_capi on UBSan#151286
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:test_capi

Conversation

@vstinner

@vstinner vstinner commented Jun 10, 2026

Copy link
Copy Markdown
Member

Remove two checks relying on undefined behavior in test_fromwidechar() of test_capi.

Enable test_capi in GitHub Action "Reusable Sanitizer".

Remove two checks relying on undefined behavior in
test_fromwidechar() of test_capi.

Enable test_capi in GitHub Action "Reusable Sanitizer".
@vstinner vstinner added skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 10, 2026
@vstinner

Copy link
Copy Markdown
Member Author
PyObject *
PyUnicode_FromWideChar(const wchar_t *u, Py_ssize_t size)
{
    ...

    if (find_maxchar_surrogates(u, u + size,
                                &maxchar, &num_surrogates) == -1)
        return NULL;

    ...
}

u + size with size=PY_SSIZE_T_MAX triggers an undefined behavior.

@vstinner

Copy link
Copy Markdown
Member Author

@serhiy-storchaka: Would you mind to review this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant