diff options
Diffstat (limited to 'vcl/source/outdev/text.cxx')
-rw-r--r-- | vcl/source/outdev/text.cxx | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 097d21c396e4..8bb77789378f 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) |