Skip to content

Commit 36208b5

Browse files
[3.11] gh-106350: Tkinter: do not ignore return value of mp_init() (GH-106351) (GH-107259)
(cherry picked from commit b5ae7c4) Co-authored-by: Christopher Chavez <[email protected]>
1 parent 9fa44d7 commit 36208b5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Detect possible memory allocation failure in the libtommath function :c:func:`mp_init`
2+
used by the ``_tkinter`` module.

Modules/_tkinter.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,9 @@ asBignumObj(PyObject *value)
906906
return NULL;
907907
}
908908
hexchars += neg + 2; /* skip sign and "0x" */
909-
mp_init(&bigValue);
910-
if (mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) {
909+
if (mp_init(&bigValue) != MP_OKAY ||
910+
mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY)
911+
{
911912
mp_clear(&bigValue);
912913
Py_DECREF(hexstr);
913914
PyErr_NoMemory();

0 commit comments

Comments
 (0)