The validation pattern added to pdf_write_color in #318 could be beneficial for other PDF writing functions to prevent similar format-related crashes.
Functions to Review
- pdf_write_move(x, y) - validate x, y coordinates
- pdf_write_line(x, y) - validate x, y coordinates
- pdf_write_line_width(width) - validate width > 0
- Other format-based write operations
Implementation
- Apply similar NaN/infinity checks where appropriate
- Ensure consistent error handling across all PDF write operations
- Add unit tests for edge cases
Benefits
- Prevent similar 'End of record' crashes
- Consistent defensive programming at I/O boundaries
- More robust PDF generation overall
This is a non-critical code quality improvement.