Skip to content

[3.14] gh-151695: Fix use-after-free of the curses screen encoding (GH-151696)#151706

Merged
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-551f8e1-3.14
Jun 19, 2026
Merged

[3.14] gh-151695: Fix use-after-free of the curses screen encoding (GH-151696)#151706
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-551f8e1-3.14

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 19, 2026

Copy link
Copy Markdown
Member

The module-global curses_screen_encoding stored a borrowed pointer to the encoding owned by the window returned by the first initscr() call. That window can be deallocated while unctrl() and ungetch(), which have no window of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)

…ing (pythonGH-151696)

The module-global curses_screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka merged commit 7b55e9a into python:3.14 Jun 19, 2026
47 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 7b55e9a93e67913d9086a7b31f5b911958f2bf14 3.13

@bedevere-app

bedevere-app Bot commented Jun 19, 2026

Copy link
Copy Markdown

GH-151723 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 19, 2026
serhiy-storchaka added a commit that referenced this pull request Jun 19, 2026
…H-151696) (GH-151706) (GH-151723)

The module-global screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e1)
(cherry picked from commit 7b55e9a)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant