summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-26 13:35:30 (GMT)
committerGitHub <noreply@github.com>2019-03-26 13:35:30 (GMT)
commit414b1cde93764cdabb0798b02af4dd7df954424d (patch)
tree9ac9b6d3a13833383a14e3fda1d99d4307e3c35e /Modules
parent871309c775fd4d72048bfaa31affd54f9934f7dd (diff)
downloadcpython-414b1cde93764cdabb0798b02af4dd7df954424d.zip
cpython-414b1cde93764cdabb0798b02af4dd7df954424d.tar.gz
cpython-414b1cde93764cdabb0798b02af4dd7df954424d.tar.bz2
bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560)
Handle memory allocation failure.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index c82ba0c..c515efe 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);