]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106350: Tkinter: do not ignore return value of `mp_init()` (GH-106351)
authorChristopher Chavez <chrischavez@gmx.us>
Tue, 25 Jul 2023 18:52:07 +0000 (13:52 -0500)
committerGitHub <noreply@github.com>
Tue, 25 Jul 2023 18:52:07 +0000 (21:52 +0300)
Misc/NEWS.d/next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst [new file with mode: 0644]
Modules/_tkinter.c

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 (file)
index 0000000..681d63a
--- /dev/null
@@ -0,0 +1,2 @@
+Detect possible memory allocation failure in the libtommath function :c:func:`mp_init`\r
+used by the ``_tkinter`` module.
index 1605606e8a470e6dcdfafe5a1b9a72c6cf125511..145a2940427e6e81a7892f1d4ac7453135f8892a 100644 (file)
@@ -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();