Skip to content

Commit 3ecf637

Browse files
[3.13] Fix a compiler warning in _randommodule.c (GH-141058) (#141064)
Fix a compiler warning in _randommodule.c (GH-141058) The test just before the cast ensures that the cast cannot overflow. Fix the warning on 32-bit Windows: Modules\_randommodule.c(525,28): warning C4244: '=': conversion from 'uint64_t' to 'Py_ssize_t', possible loss of data (cherry picked from commit 4ac16dd) Co-authored-by: Victor Stinner <[email protected]>
1 parent 91b85c5 commit 3ecf637

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_randommodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ _random_Random_getrandbits_impl(RandomObject *self, long long k)
526526
PyErr_NoMemory();
527527
return NULL;
528528
}
529-
words = (k - 1u) / 32u + 1u;
529+
words = (Py_ssize_t)((k - 1u) / 32u + 1u);
530530
wordarray = (uint32_t *)PyMem_Malloc(words * 4);
531531
if (wordarray == NULL) {
532532
PyErr_NoMemory();

0 commit comments

Comments
 (0)