This commit is contained in:
J. Nick Koston
2026-01-14 17:35:36 -10:00
parent d760a5dad3
commit c6ff6d268b

View File

@@ -410,6 +410,10 @@ char *format_bin_to(char *buffer, size_t buffer_size, const uint8_t *data, size_
}
// Calculate max bytes we can format: each byte needs 8 chars
size_t max_bytes = (buffer_size - 1) / 8;
if (max_bytes == 0 || length == 0) {
buffer[0] = '\0';
return buffer;
}
size_t bytes_to_format = std::min(length, max_bytes);
for (size_t byte_idx = 0; byte_idx < bytes_to_format; byte_idx++) {