Skip to content

Commit fc130c4

Browse files
authored
gh-102509: Start initializing ob_digit of _PyLongValue (GH-102510)
1 parent a1b6795 commit fc130c4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Start initializing ``ob_digit`` during creation of :c:type:`PyLongObject`
2+
objects. Patch by Illia Volochii.

Objects/longobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ _PyLong_New(Py_ssize_t size)
163163
}
164164
_PyLong_SetSignAndDigitCount(result, size != 0, size);
165165
_PyObject_Init((PyObject*)result, &PyLong_Type);
166+
/* The digit has to be initialized explicitly to avoid
167+
* use-of-uninitialized-value. */
168+
result->long_value.ob_digit[0] = 0;
166169
return result;
167170
}
168171

0 commit comments

Comments
 (0)