download.lst | 4 - external/pdfium/Library_pdfium.mk | 8 -- external/pdfium/UnpackedTarball_pdfium.mk | 2 external/pdfium/build.patch.1 | 40 +---------- external/pdfium/buildfix.patch.1 | 21 ++++++ external/pdfium/fa84e52-revert.patch.1 | 86 +++++++++++++++++++++++++ external/pdfium/inc/pch/precompiled_pdfium.hxx | 19 +++-- external/pdfium/ubsan.patch | 12 --- 8 files changed, 127 insertions(+), 65 deletions(-)
New commits: commit 3a7ecb45ac516bf43673176670ad0f36fcfe82bf Author: Michael Stahl <[email protected]> AuthorDate: Tue Nov 11 11:48:29 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Nov 12 08:25:00 2025 +0100 Update pdfium to 5941 - Remove part of ubsan.patch, upstream switched to FXSYS_memcpy() in those two functions, which does the same length check as our patch did. - Part of build.patch.1 doesn't apply anymore, remove the FXFT_Free() part and just assume that the new FT_Done_MM_Var() introduced in freetype-2.9 is something we can use unconditionally (at least the almalinux 8 has freetype-2.9.1). Change-Id: I77efc9921e76957edbcb68e8f3861ab5194b31e7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155678 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit 4afd83245b6ab2232032c74b1d242122fc734352) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193818 Tested-by: allotropia jenkins <[email protected]> diff --git a/download.lst b/download.lst index d0cc9b497b6f..01f5ab2eca80 100644 --- a/download.lst +++ b/download.lst @@ -455,8 +455,8 @@ PAGEMAKER_TARBALL := libpagemaker-0.0.4.tar.xz # three static lines # so that git cherry-pick # will not run into conflicts -PDFIUM_SHA256SUM := b1052ff24e9ffb11af017c444bb0f6ad508d64c9a0fb88cacb0e8210245dde06 -PDFIUM_TARBALL := pdfium-5778.tar.bz2 +PDFIUM_SHA256SUM := 9a9ce3f62de525cdfd8373a155ac549579c2c8067c6050716ca4b5cd5c11f655 +PDFIUM_TARBALL := pdfium-5941.tar.bz2 # three static lines # so that git cherry-pick # will not run into conflicts diff --git a/external/pdfium/Library_pdfium.mk b/external/pdfium/Library_pdfium.mk index 136ebd7bf7e5..0b11ba9c3f2b 100644 --- a/external/pdfium/Library_pdfium.mk +++ b/external/pdfium/Library_pdfium.mk @@ -407,14 +407,12 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxcrt/cfx_datetime \ UnpackedTarball/pdfium/core/fxcrt/bytestring \ UnpackedTarball/pdfium/core/fxcrt/cfx_bitstream \ - UnpackedTarball/pdfium/core/fxcrt/cfx_utf8decoder \ UnpackedTarball/pdfium/core/fxcrt/fx_random \ UnpackedTarball/pdfium/core/fxcrt/fx_string \ UnpackedTarball/pdfium/core/fxcrt/widestring \ UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssdata \ UnpackedTarball/pdfium/core/fxcrt/fx_codepage \ UnpackedTarball/pdfium/core/fxcrt/fx_number \ - UnpackedTarball/pdfium/core/fxcrt/cfx_utf8encoder \ UnpackedTarball/pdfium/core/fxcrt/observed_ptr \ UnpackedTarball/pdfium/core/fxcrt/string_data_template \ UnpackedTarball/pdfium/core/fxcrt/binary_buffer \ @@ -429,7 +427,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/core/fxge/dib/cfx_bitmapcomposer \ UnpackedTarball/pdfium/core/fxge/dib/cfx_bitmapstorer \ - UnpackedTarball/pdfium/core/fxge/dib/cfx_dibextractor \ UnpackedTarball/pdfium/core/fxge/dib/cfx_dibitmap \ UnpackedTarball/pdfium/core/fxge/cfx_drawutils \ UnpackedTarball/pdfium/core/fxge/dib/cfx_imagerenderer \ @@ -568,11 +565,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ UnpackedTarball/pdfium/third_party/base/memory/aligned_memory \ )) -# skia_shared -$(eval $(call gb_Library_add_generated_exception_objects,pdfium,\ - UnpackedTarball/pdfium/third_party/skia_shared/SkFloatToDecimal \ -)) - $(eval $(call gb_Library_use_externals,pdfium,\ libjpeg \ lcms2 \ diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk index 07004e8de71d..0948af0bd4cc 100644 --- a/external/pdfium/UnpackedTarball_pdfium.mk +++ b/external/pdfium/UnpackedTarball_pdfium.mk @@ -8,6 +8,8 @@ # pdfium_patches := +pdfium_patches += buildfix.patch.1 +pdfium_patches += fa84e52-revert.patch.1 pdfium_patches += ubsan.patch # Fixes build on our baseline. pdfium_patches += build.patch.1 diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1 index 909149d1d3ad..3ea20d8b8aa1 100644 --- a/external/pdfium/build.patch.1 +++ b/external/pdfium/build.patch.1 @@ -60,7 +60,7 @@ diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp index 228a0c137..bf512beb3 100644 --- a/core/fpdfdoc/cpdf_metadata.cpp +++ b/core/fpdfdoc/cpdf_metadata.cpp -@@ -77,7 +77,7 @@ std::vector<UnsupportedFeature> CPDF_Metadata::CheckForSharedForm() const { +@@ -87,7 +87,7 @@ std::vector<UnsupportedFeature> CPDF_Metadata::CheckForSharedForm() const { CFX_XMLParser parser(stream); std::unique_ptr<CFX_XMLDocument> doc = parser.Parse(); if (!doc) @@ -68,7 +68,7 @@ index 228a0c137..bf512beb3 100644 + return std::vector<UnsupportedFeature>(); std::vector<UnsupportedFeature> unsupported; - CheckForSharedFormInternal(doc->GetRoot(), &unsupported); + CheckForSharedFormInternal(/*depth=*/0, doc->GetRoot(), &unsupported); --- a/core/fxge/dib/cfx_cmyk_to_srgb.cpp 2020-09-10 17:32:37.165872018 +0200 +++ b/core/fxge/dib/cfx_cmyk_to_srgb.cpp 2020-09-10 17:33:15.870395738 +0200 @@ -1740,10 +1740,12 @@ @@ -97,36 +97,6 @@ index 9391d61ab..490ce2230 100644 } void sycc_to_rgb(int offset, -diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp -index a2a44df39..d6cedee46 100644 ---- a/core/fxge/cfx_font.cpp -+++ b/core/fxge/cfx_font.cpp -@@ -48,25 +48,9 @@ struct OUTLINE_PARAMS { - // TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be - // available to all users in the future, remove FreeMMVar() and use - // FT_Done_MM_Var() directly. --// --// Use weak symbols to check if FT_Done_MM_Var() is available at runtime. --#if !BUILDFLAG(IS_WIN) --extern "C" __attribute__((weak)) decltype(FT_Done_MM_Var) FT_Done_MM_Var; --#endif - - void FreeMMVar(FXFT_FaceRec* rec, FXFT_MM_VarPtr variation_desc) { --#if BUILDFLAG(IS_WIN) -- // Assume `use_system_freetype` GN var is never set on Windows. -- constexpr bool has_ft_done_mm_var_func = true; --#else -- static const bool has_ft_done_mm_var_func = !!FT_Done_MM_Var; --#endif -- if (has_ft_done_mm_var_func) { -- FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(), -- variation_desc); -- } else { - FXFT_Free(rec, variation_desc); -- } - } - - FX_RECT FXRectFromFTPos(FT_Pos left, FT_Pos top, FT_Pos right, FT_Pos bottom) { diff --git a/third_party/base/numerics/safe_conversions_impl.h b/third_party/base/numerics/safe_conversions_impl.h index 44c921a14..0152a89b7 100644 --- a/third_party/base/numerics/safe_conversions_impl.h @@ -140,10 +110,10 @@ index 44c921a14..0152a89b7 100644 // TODO(jschuh): Debug builds don't reliably propagate constants, so we restrict // some accelerated runtime paths to release builds until this can be forced -diff --git a/third_party/base/span.h b/third_party/base/span.h +diff --git a/third_party/base/containers/span.h b/third_party/base/containers/span.h index ed2a3c8de..87493861c 100644 ---- a/third_party/base/span.h -+++ b/third_party/base/span.h +--- a/third_party/base/containers/span.h ++++ b/third_party/base/containers/span.h @@ -211,7 +211,7 @@ class TRIVIAL_ABI GSL_POINTER span { #else template <typename Container, diff --git a/external/pdfium/buildfix.patch.1 b/external/pdfium/buildfix.patch.1 new file mode 100644 index 000000000000..60d65558fe6f --- /dev/null +++ b/external/pdfium/buildfix.patch.1 @@ -0,0 +1,21 @@ +GCC 15 fix +--- pdfium/core/fxcodec/jbig2/JBig2_DocumentContext.h.orig 2025-11-11 11:42:49.394310384 +0100 ++++ pdfium/core/fxcodec/jbig2/JBig2_DocumentContext.h 2025-11-11 11:43:00.141433331 +0100 +@@ -10,6 +10,7 @@ + #include <list> + #include <memory> + #include <utility> ++#include <cstdint> + + class CJBig2_SymbolDict; + +--- pdfium/third_party/base/containers/span.h.orig 2025-11-11 11:46:46.901027677 +0100 ++++ pdfium/third_party/base/containers/span.h 2025-11-11 11:46:48.815049574 +0100 +@@ -6,6 +6,7 @@ + #define THIRD_PARTY_BASE_CONTAINERS_SPAN_H_ + + #include <stddef.h> ++#include <stdint.h> + + #include <algorithm> + #include <array> diff --git a/external/pdfium/fa84e52-revert.patch.1 b/external/pdfium/fa84e52-revert.patch.1 new file mode 100644 index 000000000000..9041b6006013 --- /dev/null +++ b/external/pdfium/fa84e52-revert.patch.1 @@ -0,0 +1,86 @@ +From fa84e52cd9c79a800568184863186ac984592fbd Mon Sep 17 00:00:00 2001 +From: Lei Zhang <[email protected]> +Date: Mon, 05 Jun 2023 20:12:02 +0000 +Subject: Revert [PATCH] Remove FT_Done_MM_Var() workaround + +FT_Done_MM_Var() has been around since FreeType 2.9 from early 2018. Use +it directly to simplify code instead of assuming that it may not exist. +The default build, which uses a bundled FreeType, is up-to-date, so the +issue of FT_Done_MM_Var() being missing could only happen if someone is +building the code with an old system FreeType. + +Bug: pdfium:1400 +Change-Id: I7642de8884969484ff90a4cf865acc67e07e419b +Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/107510 +Reviewed-by: Dominik Röttsches <[email protected]> +Commit-Queue: Lei Zhang <[email protected]> +--- + +diff --git a/core/fxge/freetype/fx_freetype.cpp b/core/fxge/freetype/fx_freetype.cpp +index a2a44df..8b5f4fc 100644 +--- a/core/fxge/freetype/fx_freetype.cpp ++++ b/core/fxge/freetype/fx_freetype.cpp +@@ -82,13 +82,40 @@ + + } // namespace + ++// TODO(crbug.com/pdfium/1400): When FT_Done_MM_Var() is more likely to be ++// available to all users in the future, remove FreeMMVar() and use ++// FT_Done_MM_Var() directly. ++// ++// Use weak symbols to check if FT_Done_MM_Var() is available at runtime. ++#if !BUILDFLAG(IS_WIN) ++FT_EXPORT( FT_Error ) FT_Done_MM_Var( FT_Library library, FT_MM_Var *amaster ); ++extern "C" __attribute__((weak)) decltype(FT_Done_MM_Var) FT_Done_MM_Var; ++#endif ++ ++void FreeMMVar(FXFT_FaceRec* rec, FT_MM_Var* variation_desc) { ++#if BUILDFLAG(IS_WIN) ++ // Assume `use_system_freetype` GN var is never set on Windows. ++ constexpr bool has_ft_done_mm_var_func = true; ++#else ++ static const bool has_ft_done_mm_var_func = !!FT_Done_MM_Var; ++#endif ++ if (has_ft_done_mm_var_func) { ++ FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(), ++ variation_desc); ++ } else { ++ FXFT_Free(rec, variation_desc); ++ } ++} ++ + void FXFTMMVarDeleter::operator()(FT_MM_Var* variation_desc) { +- FT_Done_MM_Var(CFX_GEModule::Get()->GetFontMgr()->GetFTLibrary(), ++ FreeMMVar(m_pFace, + variation_desc); + } ++ ++FXFTMMVarDeleter::FXFTMMVarDeleter(FXFT_FaceRec* face) : m_pFace(face) {} + + ScopedFXFTMMVar::ScopedFXFTMMVar(FXFT_FaceRec* face) +- : variation_desc_(GetVariationDescriptor(face)) {} ++ : variation_desc_(GetVariationDescriptor(face), FXFTMMVarDeleter(face)) {} + + ScopedFXFTMMVar::~ScopedFXFTMMVar() = default; + +diff --git a/core/fxge/freetype/fx_freetype.h b/core/fxge/freetype/fx_freetype.h +index 3da0372..e09ca61 100644 +--- a/core/fxge/freetype/fx_freetype.h ++++ b/core/fxge/freetype/fx_freetype.h +@@ -34,6 +34,8 @@ + + struct FXFTMMVarDeleter { + void operator()(FT_MM_Var* variation_desc); ++ FXFT_FaceRec *const m_pFace; ++ FXFTMMVarDeleter(FXFT_FaceRec *); + }; + + using ScopedFXFTFaceRec = std::unique_ptr<FXFT_FaceRec, FXFTFaceRecDeleter>; +@@ -76,6 +76,7 @@ + #define FXFT_Get_Face_Ascender(face) (face)->ascender + #define FXFT_Get_Face_Descender(face) (face)->descender + #define FXFT_Get_Glyph_HoriAdvance(face) (face)->glyph->metrics.horiAdvance ++#define FXFT_Free(face, p) (face)->memory->free((face)->memory, p) + #define FXFT_Get_Glyph_Outline(face) &((face)->glyph->outline) + #define FXFT_Get_Glyph_Bitmap(face) (face)->glyph->bitmap + #define FXFT_Get_Bitmap_Width(bitmap) (bitmap).width diff --git a/external/pdfium/inc/pch/precompiled_pdfium.hxx b/external/pdfium/inc/pch/precompiled_pdfium.hxx index 6258e8036360..64795df4054d 100644 --- a/external/pdfium/inc/pch/precompiled_pdfium.hxx +++ b/external/pdfium/inc/pch/precompiled_pdfium.hxx @@ -13,7 +13,7 @@ manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). - Generated on 2022-11-08 17:05:53 using: + Generated on 2023-08-15 08:05:49 using: ./bin/update_pch external/pdfium pdfium --cutoff=1 --exclude:system --include:module --include:local If after updating build fails, use the following command to locate conflicting headers: @@ -47,6 +47,7 @@ #include <new> #include <numeric> #include <ostream> +#include <queue> #include <set> #include <setjmp.h> #include <sstream> @@ -187,6 +188,7 @@ #include <core/fpdfapi/parser/cpdf_syntax_parser.h> #include <core/fpdfapi/parser/fpdf_parser_decode.h> #include <core/fpdfapi/parser/fpdf_parser_utility.h> +#include <core/fpdfapi/parser/object_tree_traversal_util.h> #include <core/fpdfapi/render/charposlist.h> #include <core/fpdfapi/render/cpdf_devicebuffer.h> #include <core/fpdfapi/render/cpdf_docrenderdata.h> @@ -283,8 +285,7 @@ #include <core/fxcrt/cfx_read_only_vector_stream.h> #include <core/fxcrt/cfx_seekablestreamproxy.h> #include <core/fxcrt/cfx_timer.h> -#include <core/fxcrt/cfx_utf8decoder.h> -#include <core/fxcrt/cfx_utf8encoder.h> +#include <core/fxcrt/code_point_view.h> #include <core/fxcrt/css/cfx_css.h> #include <core/fxcrt/css/cfx_csscolorvalue.h> #include <core/fxcrt/css/cfx_csscomputedstyle.h> @@ -317,6 +318,7 @@ #include <core/fxcrt/fx_coordinates.h> #include <core/fxcrt/fx_extension.h> #include <core/fxcrt/fx_folder.h> +#include <core/fxcrt/fx_memcpy_wrappers.h> #include <core/fxcrt/fx_memory.h> #include <core/fxcrt/fx_memory_wrappers.h> #include <core/fxcrt/fx_number.h> @@ -337,7 +339,10 @@ #include <core/fxcrt/stl_util.h> #include <core/fxcrt/string_data_template.h> #include <core/fxcrt/string_pool_template.h> +#include <core/fxcrt/string_view_template.h> #include <core/fxcrt/unowned_ptr.h> +#include <core/fxcrt/unowned_ptr_exclusion.h> +#include <core/fxcrt/utf16.h> #include <core/fxcrt/widestring.h> #include <core/fxcrt/widetext_buffer.h> #include <core/fxcrt/xml/cfx_xmlchardata.h> @@ -374,7 +379,6 @@ #include <core/fxge/dib/cfx_bitmapstorer.h> #include <core/fxge/dib/cfx_cmyk_to_srgb.h> #include <core/fxge/dib/cfx_dibbase.h> -#include <core/fxge/dib/cfx_dibextractor.h> #include <core/fxge/dib/cfx_dibitmap.h> #include <core/fxge/dib/cfx_imagerenderer.h> #include <core/fxge/dib/cfx_imagestretcher.h> @@ -455,6 +459,7 @@ #include <public/fpdf_transformpage.h> #include <public/fpdfview.h> #include <third_party/abseil-cpp/absl/types/optional.h> +#include <third_party/abseil-cpp/absl/types/variant.h> #include <third_party/agg23/agg_clip_liang_barsky.h> #include <third_party/agg23/agg_conv_dash.h> #include <third_party/agg23/agg_conv_stroke.h> @@ -469,16 +474,14 @@ #include <third_party/base/compiler_specific.h> #include <third_party/base/containers/adapters.h> #include <third_party/base/containers/contains.h> -#include <third_party/base/cxx17_backports.h> +#include <third_party/base/containers/span.h> #include <third_party/base/debug/alias.h> #include <third_party/base/memory/aligned_memory.h> +#include <third_party/base/memory/ptr_util.h> #include <third_party/base/no_destructor.h> #include <third_party/base/notreached.h> #include <third_party/base/numerics/safe_conversions.h> #include <third_party/base/numerics/safe_math.h> -#include <third_party/base/ptr_util.h> -#include <third_party/base/span.h> -#include <third_party/skia_shared/SkFloatToDecimal.h> #endif // PCH_LEVEL >= 3 #if PCH_LEVEL >= 4 #endif // PCH_LEVEL >= 4 diff --git a/external/pdfium/ubsan.patch b/external/pdfium/ubsan.patch index bc9868244275..039505eda9cf 100644 --- a/external/pdfium/ubsan.patch +++ b/external/pdfium/ubsan.patch @@ -1,15 +1,3 @@ ---- core/fxcrt/string_data_template.cpp -+++ core/fxcrt/string_data_template.cpp -@@ -82,7 +82,8 @@ void StringDataTemplate<CharType>::CopyContentsAt(size_t offset, - DCHECK_GE(offset, 0); - DCHECK_GE(nLen, 0); - DCHECK_LE(offset + nLen, m_nAllocLength); -- memcpy(m_String + offset, pStr, nLen * sizeof(CharType)); -+ if (nLen != 0) -+ memcpy(m_String + offset, pStr, nLen * sizeof(CharType)); - m_String[offset + nLen] = 0; - } - --- core/fxge/cfx_glyphcache.cpp +++ core/fxge/cfx_glyphcache.cpp @@ -183,7 +183,8 @@ std::unique_ptr<CFX_GlyphBitmap> CFX_GlyphCache::RenderGlyph(
