Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 148e108

Browse files
committed
Remove strnlen and correctly address #1600
1 parent c90c737 commit 148e108

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/core/pp.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,19 +1060,11 @@ void janet_buffer_format(
10601060
break;
10611061
}
10621062
case 's': {
1063-
JanetByteView bytes = janet_getbytes(argv, arg);
1064-
const uint8_t *s = bytes.bytes;
1065-
int32_t l = bytes.len;
1063+
const char *s = janet_getcbytes(argv, arg);
10661064
if (form[2] == '\0')
1067-
janet_buffer_push_bytes(b, s, l);
1065+
janet_buffer_push_cstring(b, s);
10681066
else {
1069-
if (l != (int32_t) strnlen((const char *) s, l))
1070-
janet_panic("string contains zeros");
1071-
if (!strchr(form, '.') && l >= 100) {
1072-
janet_panic("no precision and string is too long to be formatted");
1073-
} else {
1074-
nb = snprintf(item, MAX_ITEM, form, s);
1075-
}
1067+
nb = snprintf(item, MAX_ITEM, form, s);
10761068
}
10771069
break;
10781070
}

0 commit comments

Comments
 (0)