diff options
| author | 2025-09-01 14:04:30 -0500 | |
|---|---|---|
| committer | 2025-09-01 14:04:30 -0500 | |
| commit | 148e1088644d78bfaff6cd87bfcf5f50476d5a03 (patch) | |
| tree | 487a5ee63c9797651d43217dca20e30dd8272e20 /src | |
| parent | Revert reordering 2. (diff) | |
Remove strnlen and correctly address #1600
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/pp.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/core/pp.c b/src/core/pp.c index 618f7515..3b000f41 100644 --- a/src/core/pp.c +++ b/src/core/pp.c @@ -1060,19 +1060,11 @@ void janet_buffer_format( break; } case 's': { - JanetByteView bytes = janet_getbytes(argv, arg); - const uint8_t *s = bytes.bytes; - int32_t l = bytes.len; + const char *s = janet_getcbytes(argv, arg); if (form[2] == '\0') - janet_buffer_push_bytes(b, s, l); + janet_buffer_push_cstring(b, s); else { - if (l != (int32_t) strnlen((const char *) s, l)) - janet_panic("string contains zeros"); - if (!strchr(form, '.') && l >= 100) { - janet_panic("no precision and string is too long to be formatted"); - } else { - nb = snprintf(item, MAX_ITEM, form, s); - } + nb = snprintf(item, MAX_ITEM, form, s); } break; } |
