Skip to content

Commit 6260b6a

Browse files
[3.13] pythongh-139146: Check calloc() results in _testembed.c::test_pre_initialization_sys_options (pythonGH-139147) (python#139414)
pythongh-139146: Check `calloc()` results in `_testembed.c::test_pre_initialization_sys_options` (pythonGH-139147) (cherry picked from commit 9c6a1f8) Reported by: Dmitrii Chuprov <[email protected]> Signed-off-by: Denis Sergeev <[email protected]> Co-authored-by: Denis Sergeev <[email protected]>
1 parent d232944 commit 6260b6a

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

0 commit comments

Comments
 (0)