kopia lustrzana https://github.com/micropython/micropython
py/sequence.c: Add an early return.
Signed-off-by: Félix Richart <felix.richart@numworks.com>pull/12131/head
rodzic
df421e0125
commit
e0a6696572
|
@ -36,7 +36,10 @@
|
|||
// Implements backend of sequence * integer operation. Assumes elements are
|
||||
// memory-adjacent in sequence.
|
||||
void mp_seq_multiply(const void *items, size_t item_sz, size_t len, size_t times, void *dest) {
|
||||
if (item_sz != 0 && len != 0 && times != 0 && (len > SIZE_MAX / item_sz || times > SIZE_MAX / (item_sz * len))) {
|
||||
if (len == 0 || times == 0 || item_sz == 0) {
|
||||
return;
|
||||
}
|
||||
if (len > SIZE_MAX / item_sz || times > SIZE_MAX / (item_sz * len)) {
|
||||
// dest couldn't be correctly allocated in memory because
|
||||
// item_sz * len * times overflows SIZE_MAX.
|
||||
m_malloc_fail(SIZE_MAX);
|
||||
|
|
Ładowanie…
Reference in New Issue