From c2003c73d71001fcb66fb86a15cde82e60aa242a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 5 May 2012 21:19:24 +0100 Subject: Related: fdo#47511 valgrind: invalid read of size 1 Change-Id: Icca307c1a9ac47201e4cd0069feb699bae2ae359 --- vcl/source/gdi/pdfwriter_impl2.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx index 71378a6db2ee..4ba5e2c8a319 100644 --- a/vcl/source/gdi/pdfwriter_impl2.cxx +++ b/vcl/source/gdi/pdfwriter_impl2.cxx @@ -1666,12 +1666,20 @@ long findBitRun( const Scanline i_pLine, long i_nStartIndex, long i_nW, bool i_b pRunTable = unsetRun; } - while( nByte == nRunByte && nIndex < i_nW ) + if( nIndex < i_nW ) { - nIndex += 8; - pByte++; - nByte = *pByte; + while( nByte == nRunByte ) + { + nIndex += 8; + + if (nIndex >= i_nW) + break; + + pByte++; + nByte = *pByte; + } } + if( nIndex < i_nW ) { nIndex += pRunTable[nByte]; -- cgit v1.2.3