terminal: don't rely on strlen(bytes) for write size

We're printing stuff to the terminal.  This may include
NUL bytes once in a while.  We shouldn't rely on strlen()
to determine how many bytes to write.
This commit is contained in:
Ray Strode 2010-11-19 15:27:12 -05:00
parent a4c7cbafd3
commit ba5054cc77

View file

@ -271,16 +271,17 @@ ply_terminal_write (ply_terminal_t *terminal,
{
va_list args;
char *string;
int size;
assert (terminal != NULL);
assert (format != NULL);
string = NULL;
va_start (args, format);
vasprintf (&string, format, args);
size = vasprintf (&string, format, args);
va_end (args);
write (terminal->fd, string, strlen (string));
write (terminal->fd, string, size);
free (string);
}