Browse Source

bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)

Handle memory allocation failure.
pull/12563/head
Victor Stinner 7 years ago
committed by GitHub
parent
commit
414b1cde93
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      Misc/NEWS.d/next/Tests/2019-03-26-13-49-21.bpo-36436.yAtN0V.rst
  2. 4
      Modules/_testcapimodule.c

1
Misc/NEWS.d/next/Tests/2019-03-26-13-49-21.bpo-36436.yAtN0V.rst

@ -0,0 +1 @@
Fix ``_testcapi.pymem_buffer_overflow()``: handle memory allocation failure.

4
Modules/_testcapimodule.c

@ -4184,6 +4184,10 @@ pymem_buffer_overflow(PyObject *self, PyObject *args)
/* Deliberate buffer overflow to check that PyMem_Free() detects
the overflow when debug hooks are installed. */
buffer = PyMem_Malloc(16);
if (buffer == NULL) {
PyErr_NoMemory();
return NULL;
}
buffer[16] = 'x';
PyMem_Free(buffer);

Loading…
Cancel
Save