office-gobmx/external/fontconfig/ubsan.patch

23 lines
818 B
Diff
Raw Normal View History

external/fontconfig: Avoid UBSan invalid-null-argument ...as seen when CppunitTest_services is run while instdir/share/fonts/ happens to still be unpopulated (which is otherwise not an issue for that test), > fcdir.c:268:11: runtime error: null pointer passed as argument 1, which is declared to never be null > /usr/include/stdlib.h:852:30: note: nonnull attribute specified here > #0 in FcDirScanConfig at workdir/UnpackedTarball/fontconfig/src/fcdir.c:268:5 > #1 in FcDirCacheScan at workdir/UnpackedTarball/fontconfig/src/fcdir.c:354:10 > #2 in FcDirCacheRead at workdir/UnpackedTarball/fontconfig/src/fcdir.c:462:10 > #3 in FcConfigAddDirList at workdir/UnpackedTarball/fontconfig/src/fccfg.c:537:10 > #4 in FcConfigAppFontAddDir at workdir/UnpackedTarball/fontconfig/src/fccfg.c:2912:10 > #5 in psp::PrintFontManager::addFontconfigDir(rtl::OString const&) at vcl/unx/generic/fontmanager/fontconfig.cxx:748:20 > #6 in psp::PrintFontManager::initialize() at vcl/unx/generic/fontmanager/fontmanager.cxx:711:17 > #7 in GenericUnixSalData::InitPrintFontManager() at vcl/unx/generic/app/gendata.cxx:51:26 > #8 in GenericUnixSalData::GetPrintFontManager() at vcl/inc/unx/gendata.hxx:88:13 > #9 in psp::PrintFontManager::get() at vcl/unx/generic/fontmanager/fontmanager.cxx:108:23 > #10 in GenPspGraphics::GetDevFontListHelper(vcl::font::PhysicalFontCollection*) at vcl/unx/generic/print/genpspgraphics.cxx:264:35 > #11 in FreeTypeTextRenderImpl::GetDevFontList(vcl::font::PhysicalFontCollection*) at vcl/unx/generic/gdi/freetypetextrender.cxx:110:5 > #12 in SvpSalGraphics::GetDevFontList(vcl::font::PhysicalFontCollection*) at vcl/headless/svptext.cxx:51:23 > #13 in OutputDevice::ImplInitFontList() const at vcl/source/outdev/font.cxx:651:17 > #14 in OutputDevice::GetDefaultFont(DefaultFontType, o3tl::strong_int<unsigned short, LanguageTypeTag>, GetDefaultFontFlags, OutputDevice const*) at vcl/source/outdev/font.cxx:532:22 > #15 in SwStdFontConfig::GetDefaultFor(unsigned short, o3tl::strong_int<unsigned short, LanguageTypeTag>) at sw/source/uibase/config/fontcfg.cxx:245:23 > #16 in SwStdFontConfig::SwStdFontConfig() at sw/source/uibase/config/fontcfg.cxx:91:30 > #17 in SwModule::SwModule(SfxObjectFactory*, SfxObjectFactory*, SfxObjectFactory*) at sw/source/uibase/app/swmodule.cxx:150:32 > #18 in std::__detail::_MakeUniq<SwModule>::__single_object std::make_unique<SwModule, SfxObjectFactory*&, SfxObjectFactory*&, SfxObjectFactory*&>(SfxObjectFactory*&, SfxObjectFactory*&, SfxObjectFactory*&) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../include/c++/13.0.0/bits/unique_ptr.h:1076:34 > #19 in SwDLL::SwDLL() at sw/source/uibase/app/swdll.cxx:98:26 > #20 in (anonymous namespace)::SwDLLInstance::SwDLLInstance() at sw/source/uibase/app/swdll.cxx:57:212 > #21 in rtl::Static<(anonymous namespace)::SwDLLInstance, (anonymous namespace)::theSwDLLInstance>::get() at include/rtl/instance.hxx:399:18 > #22 in SwGlobals::ensure() at sw/source/uibase/app/swdll.cxx:70:9 > #23 in SwXAutoTextContainer_get_implementation at sw/source/uibase/uno/unoatxt.cxx:1015:5 Change-Id: Ic0d246e6012b3cd2c9a9deb63c2af7258f31f0d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140214 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-09-20 00:41:14 -05:00
--- src/fcdir.c
+++ src/fcdir.c
@@ -265,7 +265,7 @@
/*
* Sort files to make things prettier
*/
- qsort(files->strs, files->num, sizeof(FcChar8 *), cmpstringp);
+ if (files->num != 0) qsort(files->strs, files->num, sizeof(FcChar8 *), cmpstringp);
/*
* Scan file files to build font patterns
external/fontconfig: Silence UBSan nullptr-with-offset ...during CppunitTest_cppcanvas_test, > fcserialize.c:166:54: runtime error: applying zero offset to null pointer > #0 in FcSerializeResize at workdir/UnpackedTarball/fontconfig/src/fcserialize.c:166:54 > #1 in FcSerializeSet at workdir/UnpackedTarball/fontconfig/src/fcserialize.c:204:7 > #2 in FcSerializeAlloc at workdir/UnpackedTarball/fontconfig/src/fcserialize.c:228:10 > #3 in FcStrSerializeAlloc at workdir/UnpackedTarball/fontconfig/src/fcserialize.c:274:12 > #4 in FcDirCacheBuild at workdir/UnpackedTarball/fontconfig/src/fccache.c:1255:10 > #5 in FcDirCacheScan at workdir/UnpackedTarball/fontconfig/src/fcdir.c:360:13 > #6 in FcDirCacheRead at workdir/UnpackedTarball/fontconfig/src/fcdir.c:462:10 > #7 in FcConfigAddDirList at workdir/UnpackedTarball/fontconfig/src/fccfg.c:516:10 > #8 in FcConfigAppFontAddDir at workdir/UnpackedTarball/fontconfig/src/fccfg.c:2891:10 > #9 in psp::PrintFontManager::addFontconfigDir(rtl::OString const&) at vcl/unx/generic/fontmanager/fontconfig.cxx:745:20 > #10 in psp::PrintFontManager::initialize() at vcl/unx/generic/fontmanager/fontmanager.cxx:683:17 > #11 in GenericUnixSalData::InitPrintFontManager() at vcl/unx/generic/app/gendata.cxx:65:26 > #12 in GenericUnixSalData::GetPrintFontManager() at vcl/inc/unx/gendata.hxx:100:13 > #13 in psp::PrintFontManager::get() at vcl/unx/generic/fontmanager/fontmanager.cxx:105:23 > #14 in GenPspGraphics::GetDevFontListHelper(vcl::font::PhysicalFontCollection*) at vcl/unx/generic/print/genpspgraphics.cxx:248:35 > #15 in FreeTypeTextRenderImpl::GetDevFontList(vcl::font::PhysicalFontCollection*) at vcl/unx/generic/gdi/freetypetextrender.cxx:110:5 > #16 in SvpSalGraphics::GetDevFontList(vcl::font::PhysicalFontCollection*) at vcl/headless/svptext.cxx:51:23 > #17 in OutputDevice::ImplInitFontList() const at vcl/source/outdev/font.cxx:643:17 > #18 in OutputDevice::ImplNewFont() const at vcl/source/outdev/font.cxx:700:5 > #19 in OutputDevice::InitFont() const at vcl/source/outdev/font.cxx:660:10 > #20 in OutputDevice::GetTextHeight() const at vcl/source/outdev/text.cxx:899:10 > #21 in vcl::Window::GetTextHeight() const at vcl/source/window/window3.cxx:65:65 > #22 in vcl::Window::ImplInitAppFontData(vcl::Window const*) at vcl/source/window/window.cxx:1188:40 > #23 in vcl::Window::ImplInit(vcl::Window*, long, SystemParentData*) at vcl/source/window/window.cxx:1182:9 > #24 in ImplBorderWindow::ImplInit(vcl::Window*, long, BorderWindowStyle, SystemParentData*) at vcl/source/window/brdwin.cxx:1557:13 > #25 in ImplBorderWindow::ImplBorderWindow(vcl::Window*, SystemParentData*, long, BorderWindowStyle) at vcl/source/window/brdwin.cxx:1586:5 > #26 in VclPtrInstance<ImplBorderWindow>::VclPtrInstance<vcl::Window*&, SystemParentData*&, long&, BorderWindowStyle&>(vcl::Window*&, SystemParentData*&, long&, BorderWindowStyle&) at include/vcl/vclptr.hxx:280:39 > #27 in WorkWindow::ImplInit(vcl::Window*, long, SystemParentData*) at vcl/source/window/wrkwin.cxx:51:38 > #28 in WorkWindow::WorkWindow(vcl::Window*, long) at vcl/source/window/wrkwin.cxx:95:5 > #29 in ScopedVclPtrInstance<WorkWindow>::ScopedVclPtrInstance<std::nullptr_t, long const&>(std::nullptr_t&&, long const&) at include/vcl/vclptr.hxx:412:45 > #30 in CanvasTest::testComposite() at cppcanvas/qa/unit/test.cxx:38:38 Change-Id: I90c86931ae5d4dfb32a1a95a5eb660484b54f09a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148287 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-03-05 16:41:16 -06:00
--- src/fcserialize.c
+++ src/fcserialize.c
@@ -163,7 +163,7 @@
size_t old_used = serialize->buckets_used;
size_t old_count = serialize->buckets_count;
FcSerializeBucket *old_buckets = serialize->buckets;
- FcSerializeBucket *old_buckets_end = old_buckets + old_count;
+ FcSerializeBucket *old_buckets_end = old_count == 0 ? old_buckets : old_buckets + old_count;
FcSerializeBucket *new_buckets = malloc (new_count * sizeof (*old_buckets));
if (!new_buckets)