Skip to content

Commit 2b0ccce

Browse files
[3.13] gh-139927: Fix test_embed on OpenIndiana (GH-142514) (#142521)
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 e96367d commit 2b0ccce

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
@@ -1965,15 +1965,20 @@ static int check_use_frozen_modules(const char *rawval)
19651965
if (rawval == NULL) {
19661966
wcscpy(optval, L"frozen_modules");
19671967
}
1968-
else if (swprintf(optval, 100,
1969-
#if defined(_MSC_VER)
1970-
L"frozen_modules=%S",
1971-
#else
1972-
L"frozen_modules=%s",
1973-
#endif
1974-
rawval) < 0) {
1975-
error("rawval is too long");
1976-
return -1;
1968+
else {
1969+
wchar_t *val = Py_DecodeLocale(rawval, NULL);
1970+
if (val == NULL) {
1971+
error("unable to decode TESTFROZEN");
1972+
return -1;
1973+
}
1974+
wcscpy(optval, L"frozen_modules=");
1975+
if ((wcslen(optval) + wcslen(val)) >= Py_ARRAY_LENGTH(optval)) {
1976+
error("TESTFROZEN is too long");
1977+
PyMem_RawFree(val);
1978+
return -1;
1979+
}
1980+
wcscat(optval, val);
1981+
PyMem_RawFree(val);
19771982
}
19781983

19791984
PyConfig config;

0 commit comments

Comments
 (0)