Skip to content

Commit d235542

Browse files
[3.12] gh-106350: Tkinter: do not ignore return value of mp_init() (GH-106351) (GH-107258)
(cherry picked from commit b5ae7c4) Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
1 parent ef80851 commit d235542

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,9 @@ asBignumObj(PyObject *value)
876876
return NULL;
877877
}
878878
hexchars += neg + 2; /* skip sign and "0x" */
879-
mp_init(&bigValue);
880-
if (mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) {
879+
if (mp_init(&bigValue) != MP_OKAY ||
880+
mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY)
881+
{
881882
mp_clear(&bigValue);
882883
Py_DECREF(hexstr);
883884
PyErr_NoMemory();

0 commit comments

Comments
 (0)