Skip to content

Commit 3be06fb

Browse files
committed
gh-139146: Check calloc() results in test_pre_initialization_sys_options
Reported by: Dmitrii Chuprov [email protected] Signed-off-by: Denis Sergeev [email protected]
1 parent ac5c5d4 commit 3be06fb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Programs/_testembed.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ static int test_pre_initialization_sys_options(void)
342342
(wchar_t *) calloc(warnoption_len+1, sizeof(wchar_t));
343343
wchar_t *dynamic_xoption = \
344344
(wchar_t *) calloc(xoption_len+1, sizeof(wchar_t));
345+
if (dynamic_once_warnoption == NULL) {
346+
error("out of memory allocating warnoption");
347+
return 1;
348+
}
349+
if (dynamic_xoption == NULL) {
350+
free(dynamic_once_warnoption);
351+
error("out of memory allocating xoption");
352+
return 1;
353+
}
354+
345355
wcsncpy(dynamic_once_warnoption, static_warnoption, warnoption_len+1);
346356
wcsncpy(dynamic_xoption, static_xoption, xoption_len+1);
347357

0 commit comments

Comments
 (0)