summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-24 14:47:14 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-07-24 17:58:53 +0200
commitad3595cac951d069a2b0883a18711edab138c1ab (patch)
tree24dc808763c2cc05d6357549146d20f6ea981a5a /vcl
parentd0f44c46c678837f0b30928595d82443f3d53abe (diff)
forcepoint#53 restrict to expected index range
Change-Id: I22f01e5a3e3cf51b014ac841cd14071dce5baf0f Reviewed-on: https://gerrit.libreoffice.org/57920 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
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 eb3260bdbdc9..647788129d32 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -574,13 +574,18 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs)
bool GenericSalLayout::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;
}