Request for review: "GH-60198: Prevent memoryview pointing to freed heap memory"

A memoryview that does not have a reference to its base object can point to memory that has been freed. Then a segfault error occurs when trying to access the freed memory section. You can reach the PR here.

To reproduce the case;

import io

class File(io.RawIOBase):
    def readinto(self, buf):
        global view
        view = buf
    def readable(self):
        return True

f = io.BufferedReader(File())
f.read(1)                       # get view of buffer used by BufferedReader
del f                           # deallocate buffer
view = view.cast('P')
L = [None] * len(view)          # create list whose array has same size
                                # (this will probably coincide with view)
view[0] = 0                     # overwrite first item with NULL
print(L[0])