Merge pull request #89 from vlasovsoft1979/master

Fix undefined behavior in _pdfioFileSeek
This commit is contained in:
Michael R Sweet 2025-01-18 09:42:58 -05:00 committed by GitHub
commit 5fc571b711
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -368,7 +368,7 @@ _pdfioFileSeek(pdfio_file_t *pdf, // I - PDF file
if (pdf->mode == _PDFIO_MODE_READ)
{
// Reading, see if we already have the data we need...
if (whence != SEEK_END && offset >= pdf->bufpos && offset < (pdf->bufpos + pdf->bufend - pdf->buffer))
if (whence != SEEK_END && offset >= pdf->bufpos && pdf->bufend && offset < (pdf->bufpos + pdf->bufend - pdf->buffer))
{
// Yes, seek within existing buffer...
pdf->bufptr = pdf->buffer + (offset - pdf->bufpos);