diff options
| author | Victor Stinner <vstinner@redhat.com> | 2019-03-26 14:35:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-26 14:35:30 +0100 |
| commit | 414b1cde93764cdabb0798b02af4dd7df954424d (patch) | |
| tree | 9ac9b6d3a13833383a14e3fda1d99d4307e3c35e /Modules | |
| parent | 871309c775fd4d72048bfaa31affd54f9934f7dd (diff) | |
| download | cpython-git-414b1cde93764cdabb0798b02af4dd7df954424d.tar.gz | |
bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)
Handle memory allocation failure.
Diffstat (limited to 'Modules')
| -rw-r--r-- | Modules/_testcapimodule.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index c82ba0cfd0..c515efe660 100644 --- a/Modules/_testcapimodule.c +++ b/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); |
