bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560) · python/cpython@414b1cd (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 414b1cd

Handle memory allocation failure.

File tree

2 files changed

lines changed

2 files changed

lines changed

Lines changed: 1 addition & 0 deletions

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 +Fix ``_testcapi.pymem_buffer_overflow()``: handle memory allocation failure.

Lines changed: 4 additions & 0 deletions

Original file line number Diff line number Diff line change
@@ -4184,6 +4184,10 @@ pymem_buffer_overflow(PyObject *self, PyObject *args)
4184 4184 /* Deliberate buffer overflow to check that PyMem_Free() detects
4185 4185 the overflow when debug hooks are installed. */
4186 4186 buffer = PyMem_Malloc(16);
4187 +if (buffer == NULL) {
4188 +PyErr_NoMemory();
4189 +return NULL;
4190 + }
4187 4191 buffer[16] = 'x';
4188 4192 PyMem_Free(buffer);
4189 4193