MCPcopy
hub / github.com/tinygrad/tinygrad / test_subbuffer_uaf

Method test_subbuffer_uaf

test/backend/test_subbuffer.py:169–181  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

167 sub_buf.deallocate()
168
169 def test_subbuffer_uaf(self):
170 sub_buf = self.buf.view(4, dtypes.int8, offset=3).ensure_allocated()
171 assert self.buf.as_memoryview().tolist(), list(range(10))
172 sub_buf.deallocate()
173 with self.assertRaises(AssertionError):
174 sub_buf.as_memoryview().tolist()
175 assert self.buf.as_memoryview().tolist(), list(range(10))
176
177 sub_buf = self.buf.view(4, dtypes.int8, offset=3).ensure_allocated()
178 assert sub_buf.as_memoryview().tolist(), list(range(3, 7))
179 self.buf.deallocate()
180 with self.assertRaises(AssertionError):
181 sub_buf.as_memoryview().tolist()
182
183if __name__ == '__main__':
184 unittest.main()

Callers

nothing calls this directly

Calls 5

ensure_allocatedMethod · 0.80
as_memoryviewMethod · 0.80
deallocateMethod · 0.80
viewMethod · 0.45
tolistMethod · 0.45

Tested by

no test coverage detected