Skip to content

Commit 8d94fa7

Browse files
authored
gh-151126: Add missing PyErr_NoMemory in _winapi module (#151154)
1 parent 0fa06f4 commit 8d94fa7

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
Fix a crash, when there's no memory left on a device,
2-
which happened in code compilation.
3-
Now it raises a proper :exc:`MemoryError`.
2+
which happened in:
3+
4+
- code compilation
5+
- :func:`!_winapi.CreateProcess`
6+
7+
Now these places raise proper :exc:`MemoryError` errors.

Modules/_winapi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,10 @@ gethandlelist(PyObject *mapping, const char *name, Py_ssize_t *size)
11941194
}
11951195

11961196
ret = PyMem_Malloc(*size);
1197-
if (ret == NULL)
1197+
if (ret == NULL) {
1198+
PyErr_NoMemory();
11981199
goto cleanup;
1200+
}
11991201

12001202
for (i = 0; i < PySequence_Fast_GET_SIZE(value_fast); i++) {
12011203
ret[i] = PYNUM_TO_HANDLE(PySequence_Fast_GET_ITEM(value_fast, i));
@@ -1278,6 +1280,7 @@ getattributelist(PyObject *obj, const char *name, AttributeList *attribute_list)
12781280
attribute_list->attribute_list = PyMem_Malloc(attribute_list_size);
12791281
if (attribute_list->attribute_list == NULL) {
12801282
ret = -1;
1283+
PyErr_NoMemory();
12811284
goto cleanup;
12821285
}
12831286

0 commit comments

Comments
 (0)