Skip to content

Commit 3615bab

Browse files
sobolevnmiss-islington
authored andcommitted
gh-151126: Fix missing memory errors in _interpchannelsmodule.c (GH-151239)
(cherry picked from commit 9fd1a12) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 60123e6 commit 3615bab

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