Skip to content

Commit 9fd1a12

Browse files
authored
gh-151126: Fix missing memory errors in _interpchannelsmodule.c (#151239)
1 parent ae62b53 commit 9fd1a12

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Fix a crash, when there's no memory left on a device,
2-
which happened in:
3-
4-
- code compilation
5-
- :func:`!_winapi.CreateProcess`
2+
which happened in: code compilation, :mod:`!_interpchannels` module,
3+
:func:`!_winapi.CreateProcess` function.
64

75
Now these places raise proper :exc:`MemoryError` errors.

Modules/_interpchannelsmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,8 @@ static _channelends *
921921
_channelends_new(void)
922922
{
923923
_channelends *ends = GLOBAL_MALLOC(_channelends);
924-
if (ends== NULL) {
924+
if (ends == NULL) {
925+
PyErr_NoMemory();
925926
return NULL;
926927
}
927928
ends->numsendopen = 0;
@@ -1115,6 +1116,7 @@ _channel_new(PyThread_type_lock mutex, struct _channeldefaults defaults)
11151116
assert(check_unbound(defaults.unboundop));
11161117
_channel_state *chan = GLOBAL_MALLOC(_channel_state);
11171118
if (chan == NULL) {
1119+
PyErr_NoMemory();
11181120
return NULL;
11191121
}
11201122
chan->mutex = mutex;
@@ -1313,6 +1315,7 @@ _channelref_new(int64_t cid, _channel_state *chan)
13131315
{
13141316
_channelref *ref = GLOBAL_MALLOC(_channelref);
13151317
if (ref == NULL) {
1318+
PyErr_NoMemory();
13161319
return NULL;
13171320
}
13181321
ref->cid = cid;
@@ -1698,6 +1701,7 @@ _channel_set_closing(_channelref *ref, PyThread_type_lock mutex) {
16981701
}
16991702
chan->closing = GLOBAL_MALLOC(struct _channel_closing);
17001703
if (chan->closing == NULL) {
1704+
PyErr_NoMemory();
17011705
goto done;
17021706
}
17031707
chan->closing->ref = ref;

0 commit comments

Comments
 (0)