From 4e880142205b25e6599ebbe6320e4b7bf801293f Mon Sep 17 00:00:00 2001 From: Denis Sergeev Date: Mon, 29 Sep 2025 13:08:27 +0300 Subject: [PATCH] gh-139146: Check calloc() results in test_pre_initialization_sys_options Reported by: Dmitrii Chuprov cheese@altlinux.org Signed-off-by: Denis Sergeev --- Programs/_testembed.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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);