diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-21 10:10:09 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-21 11:55:12 +0000 |
commit | 2abcb6cba9b5cd98d76d70418f6222f481fcd878 (patch) | |
tree | ecff261f47ce2de8ec5ac072a6134dd6259be128 | |
parent | 0674dd36b6a344acc3f22676d8aa09158e17062f (diff) |
coverity#1209863 rework to explicitly compare cMaxChar
Change-Id: I739cf10c5031fd7abeb0c58569d65c03e225f5e4
-rw-r--r-- | vcl/source/gdi/impfont.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vcl/source/gdi/impfont.cxx b/vcl/source/gdi/impfont.cxx index d36005a1096f..327b0d78de3b 100644 --- a/vcl/source/gdi/impfont.cxx +++ b/vcl/source/gdi/impfont.cxx @@ -209,8 +209,12 @@ bool ParseCMAP( const unsigned char* pCmap, int nLength, CmapResult& rResult ) const unsigned char* pGlyphIdPtr = pOffsetBase + 2*i + nRangeOffset; const size_t nRemainingSize = pEndValidArea - pGlyphIdPtr; const size_t nMaxPossibleRecords = nRemainingSize/2; - const size_t nRequestedRecords = cMaxChar - cMinChar + 1; - if (nRequestedRecords > nMaxPossibleRecords) { // no sane font should trigger this + if (nMaxPossibleRecords == 0) { // no sane font should trigger this + SAL_WARN("vcl.gdi", "More indexes claimed that space available in font!"); + break; + } + const size_t nMaxLegalChar = cMinChar + nMaxPossibleRecords-1; + if (cMaxChar > nMaxLegalChar) { // no sane font should trigger this SAL_WARN("vcl.gdi", "More indexes claimed that space available in font!"); break; } |