Skip to content

Commit

Permalink
Merge pull request #131 from hartwork/fix-handling-of-null-bytes
Browse files Browse the repository at this point in the history
Be robust towards input containing null bytes (regression from #98)
  • Loading branch information
hartwork authored Nov 30, 2023
2 parents ef2c97a + e53366d commit 8d42fff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ttyplot.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ bool handle_input_event(void)
redraw_needed = true; // redraw to display the error message
return true;
}

// The data we read could contain null bytes, so we replace those
// by one of the supported delimiters to not lose all input coming after.
for (size_t i = buffer_pos; i < buffer_pos + bytes_read; i++) {
if (buffer[i] == '\0') {
buffer[i] = ' ';
}
}

buffer_pos += bytes_read;

// Handle this new data.
Expand Down

0 comments on commit 8d42fff

Please sign in to comment.