diff options
author | Illia Volochii <illia.volochii@gmail.com> | 2023-07-28 13:39:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-28 13:39:54 (GMT) |
commit | fc130c47daa715d60d8925c478a96d5083e47b6a (patch) | |
tree | 5661c5efbe2237a13979cb2fb6ce01ff6bac61bf | |
parent | a1b679572e7156bc4299819e73235dc608d4a570 (diff) | |
download | cpython-fc130c47daa715d60d8925c478a96d5083e47b6a.zip cpython-fc130c47daa715d60d8925c478a96d5083e47b6a.tar.gz cpython-fc130c47daa715d60d8925c478a96d5083e47b6a.tar.bz2 |
gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510)
-rw-r--r-- | Misc/NEWS.d/next/Security/2023-03-07-21-46-29.gh-issue-102509.5ouaH_.rst | 2 | ||||
-rw-r--r-- | Objects/longobject.c | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Security/2023-03-07-21-46-29.gh-issue-102509.5ouaH_.rst b/Misc/NEWS.d/next/Security/2023-03-07-21-46-29.gh-issue-102509.5ouaH_.rst new file mode 100644 index 0000000..d1a8e8b --- /dev/null +++ b/Misc/NEWS.d/next/Security/2023-03-07-21-46-29.gh-issue-102509.5ouaH_.rst @@ -0,0 +1,2 @@ +Start initializing ``ob_digit`` during creation of :c:type:`PyLongObject` +objects. Patch by Illia Volochii. diff --git a/Objects/longobject.c b/Objects/longobject.c index 5fca55e..5d9b413 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -163,6 +163,9 @@ _PyLong_New(Py_ssize_t size) } _PyLong_SetSignAndDigitCount(result, size != 0, size); _PyObject_Init((PyObject*)result, &PyLong_Type); + /* The digit has to be initialized explicitly to avoid + * use-of-uninitialized-value. */ + result->long_value.ob_digit[0] = 0; return result; } |