]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-102509: Start initializing `ob_digit` of `_PyLongValue` (GH-102510)
authorIllia Volochii <illia.volochii@gmail.com>
Fri, 28 Jul 2023 13:39:54 +0000 (16:39 +0300)
committerGitHub <noreply@github.com>
Fri, 28 Jul 2023 13:39:54 +0000 (14:39 +0100)
Misc/NEWS.d/next/Security/2023-03-07-21-46-29.gh-issue-102509.5ouaH_.rst [new file with mode: 0644]
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 (file)
index 0000000..d1a8e8b
--- /dev/null
@@ -0,0 +1,2 @@
+Start initializing ``ob_digit`` during creation of :c:type:`PyLongObject`
+objects. Patch by Illia Volochii.
index 5fca55e5c3a2be9425add702ef588e77b1cfa82b..5d9b413861478a84929f517ae40f6ed0937d9390 100644 (file)
@@ -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;
 }