Skip to content

Commit 35df805

Browse files
[3.14] gh-139927: Fix test_embed on OpenIndiana (GH-142514) (#142520)
gh-139927: Fix test_embed on OpenIndiana (GH-142514) Avoid swprintf() function in Programs/_testembed.c since it doesn't work as expected on OpenIndiana. (cherry picked from commit c76cfe8) Co-authored-by: Victor Stinner <[email protected]>
1 parent 36d4f67 commit 35df805

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Programs/_testembed.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,15 +2116,20 @@ static int check_use_frozen_modules(const char *rawval)
21162116
if (rawval == NULL) {
21172117
wcscpy(optval, L"frozen_modules");
21182118
}
2119-
else if (swprintf(optval, 100,
2120-
#if defined(_MSC_VER)
2121-
L"frozen_modules=%S",
2122-
#else
2123-
L"frozen_modules=%s",
2124-
#endif
2125-
rawval) < 0) {
2126-
error("rawval is too long");
2127-
return -1;
2119+
else {
2120+
wchar_t *val = Py_DecodeLocale(rawval, NULL);
2121+
if (val == NULL) {
2122+
error("unable to decode TESTFROZEN");
2123+
return -1;
2124+
}
2125+
wcscpy(optval, L"frozen_modules=");
2126+
if ((wcslen(optval) + wcslen(val)) >= Py_ARRAY_LENGTH(optval)) {
2127+
error("TESTFROZEN is too long");
2128+
PyMem_RawFree(val);
2129+
return -1;
2130+
}
2131+
wcscat(optval, val);
2132+
PyMem_RawFree(val);
21282133
}
21292134

21302135
PyConfig config;

0 commit comments

Comments
 (0)