https://github.com/python/cpython/commit/9c6a1f847b648747414600f2cde18f3837505537
commit: 9c6a1f847b648747414600f2cde18f3837505537
branch: main
author: Denis Sergeev <[email protected]>
committer: picnixz <[email protected]>
date: 2025-09-29T10:40:36Z
summary:

gh-139146: Check `calloc()` results in 
`_testembed.c::test_pre_initialization_sys_options` (#139147)

Reported by: Dmitrii Chuprov <[email protected]>
Signed-off-by: Denis Sergeev <[email protected]>

files:
M Programs/_testembed.c

diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index b5047a014ac64e..76c61efeb50a75 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -340,8 +340,18 @@ static int test_pre_initialization_sys_options(void)
     size_t xoption_len = wcslen(static_xoption);
     wchar_t *dynamic_once_warnoption = \
              (wchar_t *) calloc(warnoption_len+1, sizeof(wchar_t));
+    if (dynamic_once_warnoption == NULL) {
+        error("out of memory allocating warnoption");
+        return 1;
+    }
     wchar_t *dynamic_xoption = \
              (wchar_t *) calloc(xoption_len+1, sizeof(wchar_t));
+    if (dynamic_xoption == NULL) {
+        free(dynamic_once_warnoption);
+        error("out of memory allocating xoption");
+        return 1;
+    }
+
     wcsncpy(dynamic_once_warnoption, static_warnoption, warnoption_len+1);
     wcsncpy(dynamic_xoption, static_xoption, xoption_len+1);
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to