Skip to content

Commit 146a37b

Browse files
[3.14] gh-139146: Check calloc() results in _testembed.c::test_pre_initialization_sys_options (GH-139147) (#139413)
Co-authored-by: Denis Sergeev <[email protected]>
1 parent 7a65a47 commit 146a37b

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
@@ -360,8 +360,18 @@ static int test_pre_initialization_sys_options(void)
360360
size_t xoption_len = wcslen(static_xoption);
361361
wchar_t *dynamic_once_warnoption = \
362362
(wchar_t *) calloc(warnoption_len+1, sizeof(wchar_t));
363+
if (dynamic_once_warnoption == NULL) {
364+
error("out of memory allocating warnoption");
365+
return 1;
366+
}
363367
wchar_t *dynamic_xoption = \
364368
(wchar_t *) calloc(xoption_len+1, sizeof(wchar_t));
369+
if (dynamic_xoption == NULL) {
370+
free(dynamic_once_warnoption);
371+
error("out of memory allocating xoption");
372+
return 1;
373+
}
374+
365375
wcsncpy(dynamic_once_warnoption, static_warnoption, warnoption_len+1);
366376
wcsncpy(dynamic_xoption, static_xoption, xoption_len+1);
367377

0 commit comments

Comments
 (0)