]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151126: Fix missing memory errors in `_interpchannelsmodule.c` (#151239)
authorsobolevn <mail@sobolevn.me>
Wed, 10 Jun 2026 15:59:11 +0000 (18:59 +0300)
committerGitHub <noreply@github.com>
Wed, 10 Jun 2026 15:59:11 +0000 (18:59 +0300)
Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
Modules/_interpchannelsmodule.c

index 81e87e539865ce3de11ecb6ccb15d2b6f732d458..67e2ce4044431f9774380344450cd5d8aff64da6 100644 (file)
@@ -1,7 +1,5 @@
 Fix a crash, when there's no memory left on a device,
-which happened in:
-
-- code compilation
-- :func:`!_winapi.CreateProcess`
+which happened in: code compilation, :mod:`!_interpchannels` module,
+:func:`!_winapi.CreateProcess` function.
 
 Now these places raise proper :exc:`MemoryError` errors.
index c6d107d243dda0e2b3f075f86b3cf366be34ae3b..3614890757d69da7d3ae34d72e4533ffb929a61c 100644 (file)
@@ -921,7 +921,8 @@ static _channelends *
 _channelends_new(void)
 {
     _channelends *ends = GLOBAL_MALLOC(_channelends);
-    if (ends== NULL) {
+    if (ends == NULL) {
+        PyErr_NoMemory();
         return NULL;
     }
     ends->numsendopen = 0;
@@ -1115,6 +1116,7 @@ _channel_new(PyThread_type_lock mutex, struct _channeldefaults defaults)
     assert(check_unbound(defaults.unboundop));
     _channel_state *chan = GLOBAL_MALLOC(_channel_state);
     if (chan == NULL) {
+        PyErr_NoMemory();
         return NULL;
     }
     chan->mutex = mutex;
@@ -1313,6 +1315,7 @@ _channelref_new(int64_t cid, _channel_state *chan)
 {
     _channelref *ref = GLOBAL_MALLOC(_channelref);
     if (ref == NULL) {
+        PyErr_NoMemory();
         return NULL;
     }
     ref->cid = cid;
@@ -1698,6 +1701,7 @@ _channel_set_closing(_channelref *ref, PyThread_type_lock mutex) {
     }
     chan->closing = GLOBAL_MALLOC(struct _channel_closing);
     if (chan->closing == NULL) {
+        PyErr_NoMemory();
         goto done;
     }
     chan->closing->ref = ref;