Skip to content

Commit

Permalink
Don't ignore buffer length when printing (#1768)
Browse files Browse the repository at this point in the history
As a left-over from when Pony strings where null terminated,
pony_os_std_print wasn't checking the length of the passed in
buffer and would print the entire buffer and beyond until it
hit a null terminator.

This PR fixes that issue so that we will now correctly only
print `len` elements from the buffer.
  • Loading branch information
SeanTAllen authored and jemc committed Mar 29, 2017
1 parent 171ea72 commit 15ac347
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libponyrt/lang/stdfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ PONY_API void pony_os_std_print(FILE* fp, char* buffer, size_t len)
if(len == 0)
return;

fprintf(fp, "%s\n", buffer);
fprintf(fp, "%*.*s\n", (int)len, (int)len, buffer);
}

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

0 comments on commit 15ac347

Please sign in to comment.