From 156a184a452e906abacbcb2f5321b27694f82d4d Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 4 Sep 2025 14:37:42 -0400 Subject: [PATCH] Fix some Clang warnings. --- pdfio-content.c | 5 +++++ pdfio-file.c | 6 +++--- ttf.c | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pdfio-content.c b/pdfio-content.c index 22b8daf..de7da63 100644 --- a/pdfio-content.c +++ b/pdfio-content.c @@ -2452,9 +2452,14 @@ copy_jpeg(pdfio_dict_t *dict, // I - Dictionary // Expand our ICC buffer... if ((icc_temp = realloc(icc_data, icc_datalen + length)) == NULL) + { + free(icc_data); return (NULL); + } else + { icc_data = icc_temp; + } // Read the chunk into the ICC buffer... do diff --git a/pdfio-file.c b/pdfio-file.c index 0e52124..7bb205b 100644 --- a/pdfio-file.c +++ b/pdfio-file.c @@ -1150,7 +1150,7 @@ pdfioFileOpen( pdf->version = strdup(line + 5); // Grab the last 1k of the file to find the start of the xref table... - if (_pdfioFileSeek(pdf, 1 - sizeof(line), SEEK_END) < 0) + if (_pdfioFileSeek(pdf, 1 - (int)sizeof(line), SEEK_END) < 0) { _pdfioFileError(pdf, "Unable to read startxref data."); goto error; @@ -2829,7 +2829,7 @@ write_trailer(pdfio_file_t *pdf) // I - PDF file // Write the "free" 0 object... memset(buffer, 0, sizeof(buffer)); - pdfioStreamWrite(xref_st, buffer, offsize + 2); + pdfioStreamWrite(xref_st, buffer, (size_t)offsize + 2); // Then write the "allocated" objects... buffer[0] = 1; @@ -2899,7 +2899,7 @@ write_trailer(pdfio_file_t *pdf) // I - PDF file #endif // !_WIN32 } - if (!pdfioStreamWrite(xref_st, buffer, offsize + 2)) + if (!pdfioStreamWrite(xref_st, buffer, (size_t)offsize + 2)) { _pdfioFileError(pdf, "Unable to write cross-reference table."); ret = false; diff --git a/ttf.c b/ttf.c index 61efaab..ec9d538 100644 --- a/ttf.c +++ b/ttf.c @@ -1195,7 +1195,7 @@ static bool // O - `true` on success, `false` on failure fd_seek_cb(ttf_t *font, // I - Font size_t offset) // I - Offset in data { - return (lseek(font->file_fd, offset, SEEK_SET) == offset); + return (lseek(font->file_fd, (off_t)offset, SEEK_SET) == (off_t)offset); }