summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-24 14:47:14 +0100
committerAndras Timar <andras.timar@collabora.com>2018-08-10 10:56:48 +0200
commitc93f50342d44f43596014b577a09f52b1bf966c2 (patch)
tree4b7cfc9b5a6883da73d89f1ab70af904b4d2bfa2 /vcl
parentc21a5229f4288c251fde34abf47c2ad303269d0c (diff)
forcepoint#53 restrict to expected index range
Change-Id: I22f01e5a3e3cf51b014ac841cd14071dce5baf0f Reviewed-on: https://gerrit.libreoffice.org/57922 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit fa82b6a5c74b527dc2aed9d3b63c997580cdb277)
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index cfd86ed27409..3a7969547742 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -815,13 +815,18 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
bool CommonSalLayout::GetCharWidths(DeviceCoordinate* pCharWidths) const
{
- int nCharCount = mnEndCharPos - mnMinCharPos;
+ const int nCharCount = mnEndCharPos - mnMinCharPos;
for (int i = 0; i < nCharCount; ++i)
pCharWidths[i] = 0;
for (auto const& aGlyphItem : m_GlyphItems)
- pCharWidths[aGlyphItem.mnCharPos - mnMinCharPos] += aGlyphItem.mnNewWidth;
+ {
+ const int nIndex = aGlyphItem.mnCharPos - mnMinCharPos;
+ if (nIndex >= nCharCount)
+ continue;
+ pCharWidths[nIndex] += aGlyphItem.mnNewWidth;
+ }
return true;
}