https://github.com/python/cpython/commit/c0b9c09bd61f264bf905a8130d583072a9297876
commit: c0b9c09bd61f264bf905a8130d583072a9297876
branch: 3.15
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-10-10T10:44:59Z
summary:

[3.15] gh-156953: Fix a reference leak in curses window.insnstr() (GH-156954) 
(GH-159108)

insnstr() did not release the bytes object it converted its argument to
when setting the attributes failed, unlike addstr(), addnstr() and
insstr().
(cherry picked from commit 23180c50082fe98784c78511b335d7274ed87fb7)

Co-authored-by: Vyron Vasileiadis <[email protected]>

files:
M Modules/_cursesmodule.c

diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index f2afd60b1fc9a7..6e2522def97e26 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -2410,6 +2410,7 @@ _curses_window_insnstr_impl(PyCursesWindowObject *self, 
int group_left_1,
         attr_old = getattrs(self->win);
         if (curses_wattrset(self, attr, "insnstr") < 0) {
             curses_release_wstr(strtype, wstr);
+            Py_XDECREF(bytesobj);
             return NULL;
         }
     }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to