aports/testing/texmaker/fix-for-pdfium.patch
2024-09-28 21:15:21 +00:00

47 lines
2.1 KiB
Diff

diff --git a/3rdparty/pdfium/fpdfsdk/fpdf_dataavail_embeddertest.cpp b/3rdparty/pdfium/fpdfsdk/fpdf_dataavail_embeddertest.cpp
index cc95c1b..e40ca2e 100644
--- a/3rdparty/pdfium/fpdfsdk/fpdf_dataavail_embeddertest.cpp
+++ b/3rdparty/pdfium/fpdfsdk/fpdf_dataavail_embeddertest.cpp
@@ -12,6 +12,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/test_support.h"
#include "testing/utils/path_service.h"
+#include "third_party/base/numerics/safe_conversions.h"
namespace {
class TestAsyncLoader : public FX_DOWNLOADHINTS, FX_FILEAVAIL {
@@ -24,7 +25,8 @@ class TestAsyncLoader : public FX_DOWNLOADHINTS, FX_FILEAVAIL {
if (!file_contents_)
return;
- file_access_.m_FileLen = static_cast<unsigned long>(file_length_);
+ file_access_.m_FileLen =
+ pdfium::base::checked_cast<unsigned long>(file_length_);
file_access_.m_GetBlock = SGetBlock;
file_access_.m_Param = this;
@@ -107,8 +109,8 @@ class TestAsyncLoader : public FX_DOWNLOADHINTS, FX_FILEAVAIL {
int GetBlockImpl(unsigned long pos, unsigned char* pBuf, unsigned long size) {
if (!IsDataAvailImpl(pos, size))
return 0;
- const unsigned long end =
- std::min(static_cast<unsigned long>(file_length_), pos + size);
+ const unsigned long end = std::min(
+ pdfium::base::checked_cast<unsigned long>(file_length_), pos + size);
if (end <= pos)
return 0;
memcpy(pBuf, file_contents_.get() + pos, end - pos);
diff --git a/3rdparty/pdfium/testing/embedder_test.cpp b/3rdparty/pdfium/testing/embedder_test.cpp
index c23b5c8..f8fd2a1 100644
--- a/3rdparty/pdfium/testing/embedder_test.cpp
+++ b/3rdparty/pdfium/testing/embedder_test.cpp
@@ -130,7 +130,8 @@ bool EmbedderTest::OpenDocument(const std::string& filename,
EXPECT_TRUE(!loader_);
loader_ = new TestLoader(file_contents_.get(), file_length_);
- file_access_.m_FileLen = static_cast<unsigned long>(file_length_);
+ file_access_.m_FileLen =
+ pdfium::base::checked_cast<unsigned long>(file_length_);
file_access_.m_GetBlock = TestLoader::GetBlock;
file_access_.m_Param = loader_;