mirror of
https://github.com/python/cpython.git
synced 2026-01-26 12:55:08 +00:00
Fix a compiler warning in _randommodule.c (#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
This commit is contained in:
parent
8d55faf2d6
commit
4ac16dd109
@ -522,7 +522,7 @@ _random_Random_getrandbits_impl(RandomObject *self, uint64_t k)
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
words = (k - 1u) / 32u + 1u;
|
||||
words = (Py_ssize_t)((k - 1u) / 32u + 1u);
|
||||
wordarray = (uint32_t *)PyMem_Malloc(words * 4);
|
||||
if (wordarray == NULL) {
|
||||
PyErr_NoMemory();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user