From de7b4e72e9b0b3fb5254cc2b4d8c1c920ac26ca2 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Sun, 2 Jul 2023 22:29:08 -0500 Subject: [PATCH 1/2] gh-106350: do not ignore return value of `mp_init()` --- Modules/_tkinter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 76af803bd6eefb..ac85de05dda94c 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -874,8 +874,9 @@ asBignumObj(PyObject *value) return NULL; } hexchars += neg + 2; /* skip sign and "0x" */ - mp_init(&bigValue); - if (mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) { + if (mp_init(&bigValue) != MP_OKAY || + mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) + { mp_clear(&bigValue); Py_DECREF(hexstr); PyErr_NoMemory(); From 4705f85884ce42a80befd85727f1c3373e41040c Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 03:46:21 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst diff --git a/Misc/NEWS.d/next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst b/Misc/NEWS.d/next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst new file mode 100644 index 00000000000000..681d63a6668be8 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst @@ -0,0 +1,2 @@ +Detect possible memory allocation failure in the libtommath function :c:func:`mp_init` +used by the ``_tkinter`` module.