gh-102509: Start initializing ob_digit of _PyLongValue (GH-102510)

This commit is contained in:
Illia Volochii 2023-07-28 16:39:54 +03:00 committed by GitHub
parent a1b679572e
commit fc130c47da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Start initializing ``ob_digit`` during creation of :c:type:`PyLongObject`
objects. Patch by Illia Volochii.

View 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;
}