Skip to content

Commit 1d74300

Browse files
authored
[3.13] gh-151126: Fix missing memory errors in _interpchannelsmodule.c (GH-151239) (#151338)
(cherry picked from commit 9fd1a12)
1 parent 06dce35 commit 1d74300

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix a crash, when there's no memory left on a device,
2+
which happened in :mod:`!_interpchannels` module.
3+
4+
Now it raises proper :exc:`MemoryError` errors.

Modules/_interpchannelsmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ static _channelends *
903903
_channelends_new(void)
904904
{
905905
_channelends *ends = GLOBAL_MALLOC(_channelends);
906-
if (ends== NULL) {
906+
if (ends == NULL) {
907+
PyErr_NoMemory();
907908
return NULL;
908909
}
909910
ends->numsendopen = 0;
@@ -1095,6 +1096,7 @@ _channel_new(PyThread_type_lock mutex, int unboundop)
10951096
{
10961097
_channel_state *chan = GLOBAL_MALLOC(_channel_state);
10971098
if (chan == NULL) {
1099+
PyErr_NoMemory();
10981100
return NULL;
10991101
}
11001102
chan->mutex = mutex;
@@ -1295,6 +1297,7 @@ _channelref_new(int64_t cid, _channel_state *chan)
12951297
{
12961298
_channelref *ref = GLOBAL_MALLOC(_channelref);
12971299
if (ref == NULL) {
1300+
PyErr_NoMemory();
12981301
return NULL;
12991302
}
13001303
ref->cid = cid;
@@ -1680,6 +1683,7 @@ _channel_set_closing(_channelref *ref, PyThread_type_lock mutex) {
16801683
}
16811684
chan->closing = GLOBAL_MALLOC(struct _channel_closing);
16821685
if (chan->closing == NULL) {
1686+
PyErr_NoMemory();
16831687
goto done;
16841688
}
16851689
chan->closing->ref = ref;

0 commit comments

Comments
 (0)