diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-03-26 08:39:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-26 08:39:03 -0700 |
commit | 20fde53a25aefd076d8478f67d6db3908459c6f3 (patch) | |
tree | 8cb387840a72f9e2e0131aad028e6997ad7bd010 /Modules | |
parent | 03440850e7266aa7fd531c7f281a3fdcf17f90a4 (diff) | |
download | cpython-git-20fde53a25aefd076d8478f67d6db3908459c6f3.tar.gz |
bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)
Handle memory allocation failure.
(cherry picked from commit 414b1cde93764cdabb0798b02af4dd7df954424d)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
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 eb050ff112..1e33ca872d 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4175,6 +4175,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); |