From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 29 Sep 2025 12:04:47 +0000 (+0200) Subject: [3.14] gh-139146: Check `calloc()` results in `_testembed.c::test_pre_initialization_... X-Git-Tag: v3.14.0~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=146a37b458a8c3677f42d328644bea31863c498d;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-139146: Check `calloc()` results in `_testembed.c::test_pre_initialization_sys_options` (GH-139147) (#139413) Co-authored-by: Denis Sergeev --- diff --git a/Programs/_testembed.c b/Programs/_testembed.c index 8a7412c7019e..93625713b330 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -360,8 +360,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);