bpo-36436: Fix _testcapi.pymem_buffer_overflow() (GH-12560) · python/cpython@414b1cd (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
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 |