8000 Add note to longintrepr.h to clarify that ob_digit[0] is always safe … · python/cpython@2ddd5c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ddd5c1

Browse files
committed
Add note to longintrepr.h to clarify that ob_digit[0] is always safe to access.
1 parent ee51432 commit 2ddd5c1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Include/cpython/longintrepr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ typedef long stwodigits; /* signed variant of twodigits */
7171
0 <= ob_digit[i] <= MASK.
7272
The allocation function takes care of allocating extra memory
7373
so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available.
74+
We always allocate memory for at least one digit, so accessing ob_digit[0]
75+
is always safe. However, in the case ob_size == 0, the contents of
76+
ob_digit[0] may be undefined.
7477
7578
CAUTION: Generic code manipulating subtypes of PyVarObject has to
7679
aware that ints abuse ob_size's sign bit.

0 commit comments

Comments
 (0)
0