]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-139146: Check `calloc()` results in `_testembed.c::test_pre_initialization_sys_opt...
authorDenis Sergeev <zeff@altlinux.org>
Mon, 29 Sep 2025 10:40:36 +0000 (13:40 +0300)
committerGitHub <noreply@github.com>
Mon, 29 Sep 2025 10:40:36 +0000 (10:40 +0000)
Reported by: Dmitrii Chuprov <cheese@altlinux.org>
Signed-off-by: Denis Sergeev <zeff@altlinux.org>
Programs/_testembed.c

index b5047a014ac64e251fa5ee497e9f4c09fcee2d7e..76c61efeb50a75a5282162c9d51bf46aa587ae5a 100644 (file)
@@ -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);