Skip to content

Commit b4619e8

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 b4619e8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Programs/_testembed.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,13 @@ 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 || dynamic_xoption == NULL) {
346+
free(dynamic_once_warnoption);
347+
free(dynamic_xoption);
348+
error("out of memory allocating warn/x options");
349+
return 1;
350+
}
351+
345352
wcsncpy(dynamic_once_warnoption, static_warnoption, warnoption_len+1);
346353
wcsncpy(dynamic_xoption, static_xoption, xoption_len+1);
347354

0 commit comments

Comments
 (0)