FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-151126: Add missing `PyErr_NoMemory` in `_winapi` module by sobolevn · Pull Request #151154 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Fix a crash, when there's no memory left on a device,
which happened in code compilation.
Now it raises a proper :exc:`MemoryError`.
which happened in:

- code compilation
- :func:`!_winapi.CreateProcess`

Now these places raise proper :exc:`MemoryError` errors.
5 changes: 4 additions & 1 deletion Modules/_winapi.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1194,8 +1194,10 @@ gethandlelist(PyObject *mapping, const char *name, Py_ssize_t *size)
}

ret = PyMem_Malloc(*size);
if (ret == NULL)
if (ret == NULL) {
PyErr_NoMemory();
goto cleanup;
}

for (i = 0; i < PySequence_Fast_GET_SIZE(value_fast); i++) {
ret[i] = PYNUM_TO_HANDLE(PySequence_Fast_GET_ITEM(value_fast, i));
Expand Down Expand Up @@ -1278,6 +1280,7 @@ getattributelist(PyObject *obj, const char *name, AttributeList *attribute_list)
attribute_list->attribute_list = PyMem_Malloc(attribute_list_size);
if (attribute_list->attribute_list == NULL) {
ret = -1;
PyErr_NoMemory();
goto cleanup;
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL