Skip to content

Commit b5ae7c4

Browse files
authored
gh-106350: Tkinter: do not ignore return value of mp_init() (GH-106351)
1 parent 2b1a81e commit b5ae7c4

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
@@ -874,8 +874,9 @@ asBignumObj(PyObject *value)
874874
return NULL;
875875
}
876876
hexchars += neg + 2; /* skip sign and "0x" */
877-
mp_init(&bigValue);
878-
if (mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) {
877+
if (mp_init(&bigValue) != MP_OKAY ||
878+
mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY)
879+
{
879880
mp_clear(&bigValue);
880881
Py_DECREF(hexstr);
881882
PyErr_NoMemory();

0 commit comments

Comments
 (0)