Skip to content

Commit 5f4e2e8

Browse files
committed
gh-151126: Fix missing memory errors in _interpchannelsmodule.c
1 parent 3ca93ab commit 5f4e2e8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ which happened in:
33

44
- code compilation
55
- :func:`!_winapi.CreateProcess`
6+
- :mod:`!_interpchannels` module
67

78
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)