summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2022-04-08 11:21:09 +0200
committerAlbert Astals Cid <aacid@kde.org>2022-04-08 13:44:29 +0200
commitb1ad047408152e4a36f170728b6e97784fa48395 (patch)
tree730f542e5ea7686d296b555d2913ec14ec81dcf8
parent6f9f838341173667d2a253df64f1706392649564 (diff)
MSVC: type conversion warning fix
Don't support adding fonts bigger than INT_MAX
-rw-r--r--poppler/Form.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/poppler/Form.cc b/poppler/Form.cc
index a7bf9aba..0aafd912 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -2807,8 +2807,13 @@ std::string Form::addFontToDefaultResources(const std::string &filepath, int fac
error(errIO, -1, "Failed to get file size for %s", filepath.c_str());
return {};
}
+ // GooFile::read only takes an integer so for now we don't support huge fonts
+ if (fileSize > std::numeric_limits<int>::max()) {
+ error(errIO, -1, "Font size is too big %s", filepath.c_str());
+ return {};
+ }
char *dataPtr = static_cast<char *>(gmalloc(fileSize));
- const Goffset bytesRead = file->read(dataPtr, fileSize, 0);
+ const Goffset bytesRead = file->read(dataPtr, static_cast<int>(fileSize), 0);
if (bytesRead != fileSize) {
error(errIO, -1, "Failed to read contents of %s", filepath.c_str());
gfree(dataPtr);