Skip to content

Commit b589861

Browse files
committed
Do not use 'strdup' for compatibility with MUSL libc.
1 parent 9989c3a commit b589861

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

graalpython/com.oracle.graal.python.cext/src/unicodeobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,15 @@ PyObject* PyTruffle_Unicode_FromFormat(const char* fmt, int s, void* v0, void* v
138138
case 19: v19 = value; break; \
139139
}
140140

141-
char* fmtcpy = strdup(fmt);
141+
size_t fmt_size = strlen(fmt) + 1;
142+
// n.b. avoid using 'strdup' for compatiblity with MUSL libc
143+
char* fmtcpy = (char*) malloc(fmt_size*sizeof(char));
142144
char* c = fmtcpy;
143145
char* allocated;
144146
int cnt = 0;
145147

148+
memcpy(fmtcpy, fmt, fmt_size);
149+
146150
while (c[0] && cnt < s) {
147151
if (c[0] == '%') {
148152
switch (c[1]) {

0 commit comments

Comments
 (0)