Fix overflow handling for inplace sequence repetition (#8270)

This commit is contained in:
SeungJe Jeong authored and GitHub committed 2026-07-15 23:43:29 +09:00
1 parent 74b598ecac
commit bb49898b7b
2 files changed
+6 -1

No files matched your search

-1
View File
@@ -106,7 +106,6 @@ class ListTest(list_tests.CommonTest):
x[:] = x
self.assertEqual(x, [])
@unittest.skip("TODO: RUSTPYTHON; crash")
def test_list_resize_overflow(self):
# gh-97616: test new_allocated * sizeof(PyObject*) overflow
# check in list_resize()
+6
View File
@@ -122,6 +122,12 @@ where
fn imul(&mut self, vm: &VirtualMachine, n: isize) -> PyResult<()> {
let n = vm.check_repeat_or_overflow_error(self.as_ref().len(), n)?;
if n > 1 && core::mem::size_of_val(self.as_ref()) >= MAX_MEMORY_SIZE / n {
// TODO: make a global static NoMemory shared exc object and return its reference.
return Err(vm.new_memory_error(""));
}
if n == 0 {
self.as_vec_mut().clear();
} else if n != 1 {