Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in StdStream.print #4180

Merged
merged 9 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .release-notes/4180.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Fix bug in `StdStream.print`

When printing via `StdStream.print` strings containing null bytes, the standard library was printing the string until the first null byte and then padding the printed string with space characters until the string size was reached.

This bug was introduced in Pony 0.12.0 while fixing a different printing bug.

We've fixed the bug so that printing strings with null bytes works as expected.
6 changes: 2 additions & 4 deletions src/libponyrt/lang/stdfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,8 @@ PONY_API size_t pony_os_stdin_read(char* buffer, size_t space)

PONY_API void pony_os_std_print(FILE* fp, char* buffer, size_t len)
{
if(len == 0)
fprintf(fp, "\n");
else
fprintf(fp, "%*.*s\n", (int)len, (int)len, buffer);
fwrite(buffer, len, 1, fp);
fprintf(fp, "\n");
}

PONY_API void pony_os_std_write(FILE* fp, char* buffer, size_t len)
Expand Down