[Python-checkins] [3.12] gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510) (#107464)

Yhg1s webhook-mailer at python.org
Mon Jul 31 08:28:03 EDT 2023


https://github.com/python/cpython/commit/8f080a290bd45f4664d3a457256310cc02883d7d
commit: 8f080a290bd45f4664d3a457256310cc02883d7d
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Yhg1s <thomas at python.org>
date: 2023-07-31T14:27:59+02:00
summary:

[3.12] gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510) (#107464)

gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510)
(cherry picked from commit fc130c47daa715d60d8925c478a96d5083e47b6a)

Co-authored-by: Illia Volochii <illia.volochii at gmail.com>

files:
A Misc/NEWS.d/next/Security/2023-03-07-21-46-29.gh-issue-102509.5ouaH_.rst
M Objects/longobject.c

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 0000000000000..d1a8e8b5a8d3c
--- /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 5fca55e5c3a2b..5d9b413861478 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;
 }
 



More information about the Python-checkins mailing list