vcl/source/outdev/font.cxx | 6 ++++++ vcl/source/outdev/text.cxx | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
New commits: commit e6e409b684f9b046dcde9f0615018508f769c369 Author: Michael Stahl <mst...@redhat.com> Date: Wed Nov 25 22:42:16 2015 +0100 vcl: OutputDevice::GetTextArray() should always init pDXAry CppunitTest_writerperfect_writer file libmwaw/pass/Acta_1.0.hqx uses the font "Courier", and for unknown reasons we can't properly load that font, because the PhysicalFontFamily::mpFirst for "courier" is null. This causes OutputDevice::GetTextArray() to fail to create a SalLayout and return early before initializing the passed pDXAry, which then generates lots of DrMemory warnings. Let's hope the callers are happy about an all-0 pDXAry. Change-Id: I07b29a59660cf5cd060fd77da5d96021f9d8f9f5 diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 097d21c..8bb7778 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1006,7 +1006,7 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry, } if( nIndex >= rStr.getLength() ) - return 0; + return 0; // TODO: this looks like a buggy caller? if( nLen < 0 || nIndex + nLen >= rStr.getLength() ) { @@ -1016,7 +1016,19 @@ long OutputDevice::GetTextArray( const OUString& rStr, long* pDXAry, SalLayout *const pSalLayout = ImplLayout(rStr, nIndex, nLen, Point(0,0), 0, nullptr, SalLayoutFlags::NONE, pLayoutCache); if( !pSalLayout ) + { + // The caller expects this to init the elements of pDXAry. + // Adapting all the callers to check that GetTextArray succeeded seems + // too much work. + // Init here to 0 only in the (rare) error case, so that any missing + // element init in the happy case will still be found by tools, + // and hope that is sufficient. + if (pDXAry) + { + memset(pDXAry, 0, nLen * sizeof(*pDXAry)); + } return 0; + } #if VCL_FLOAT_DEVICE_PIXEL std::unique_ptr<DeviceCoordinate[]> pDXPixelArray; if(pDXAry) commit b6e354b26bfe2c0790c5817cba3cc3a6dad910b9 Author: Michael Stahl <mst...@redhat.com> Date: Wed Nov 25 21:49:43 2015 +0100 vcl: warn if we can't set a new font in OutputDevice Change-Id: I7708590d0c8564271f76e8b80adc566022e6916e diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 5f9f07d..f2885f0 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1546,7 +1546,10 @@ bool OutputDevice::ImplNewFont() const // we need a graphics if ( !mpGraphics && !AcquireGraphics() ) + { + SAL_WARN("vcl.gdi", "OutputDevice::ImplNewFont(): no Graphics, no Font"); return false; + } SalGraphics* pGraphics = mpGraphics; ImplInitFontList(); @@ -1577,7 +1580,10 @@ bool OutputDevice::ImplNewFont() const ImplFontEntry* pFontEntry = mpFontEntry; if (!pFontEntry) + { + SAL_WARN("vcl.gdi", "OutputDevice::ImplNewFont(): no ImplFontEntry, no Font"); return false; + } // mark when lower layers need to get involved mbNewFont = false; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits