Skip to content

Commit 414b1cd

Browse files
authored
bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)
Handle memory allocation failure.
1 parent 871309c commit 414b1cd

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix ``_testcapi.pymem_buffer_overflow()``: handle memory allocation failure.

Modules/_testcapimodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4184,6 +4184,10 @@ pymem_buffer_overflow(PyObject *self, PyObject *args)
41844184
/* Deliberate buffer overflow to check that PyMem_Free() detects
41854185
the overflow when debug hooks are installed. */
41864186
buffer = PyMem_Malloc(16);
4187+
if (buffer == NULL) {
4188+
PyErr_NoMemory();
4189+
return NULL;
4190+
}
41874191
buffer[16] = 'x';
41884192
PyMem_Free(buffer);
41894193

0 commit comments

Comments
 (0)