There was an error while loading. Please reload this page.
mp_init()
1 parent 415d3c2 commit 1031213Copy full SHA for 1031213
2 files changed
Misc/NEWS.d/next/Library/2023-07-03-03-46-20.gh-issue-106350.LLcTEe.rst
@@ -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
@@ -874,8 +874,9 @@ asBignumObj(PyObject *value)
874
return NULL;
875
}
876
hexchars += neg + 2; /* skip sign and "0x" */
877
- mp_init(&bigValue);
878
- if (mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY) {
+ if (mp_init(&bigValue) != MP_OKAY ||
+ mp_read_radix(&bigValue, hexchars, 16) != MP_OKAY)
879
+ {
880
mp_clear(&bigValue);
881
Py_DECREF(hexstr);
882
PyErr_NoMemory();
0 commit comments