vcl/source/filter/ipict/ipict.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 052afc10c565940fa947e56c49e132aeb94ae03c
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Sep 5 09:33:47 2021 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Sep 5 14:32:59 2021 +0200

    ofz: MemorySanitizer: use-of-uninitialized-value
    
    Change-Id: Ib63d500480a78a144b127c4230542507132d0a5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121669
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/filter/ipict/ipict.cxx 
b/vcl/source/filter/ipict/ipict.cxx
index 8c9494c36448..d434763dd4be 100644
--- a/vcl/source/filter/ipict/ipict.cxx
+++ b/vcl/source/filter/ipict/ipict.cxx
@@ -1602,8 +1602,6 @@ sal_uInt64 PictReader::ReadData(sal_uInt16 nOpcode)
         break;
 
     case 0x002c: { // fontName
-        char        sFName[ 256 ], nByteLen;
-        sal_uInt16  nLen;
         pPict->ReadUInt16( nUSHORT ); nDataSize=nUSHORT+2;
         pPict->ReadUInt16( nUSHORT );
         if      (nUSHORT <=    1) aActFont.SetFamily(FAMILY_SWISS);
@@ -1614,9 +1612,11 @@ sal_uInt64 PictReader::ReadData(sal_uInt16 nOpcode)
         else if (nUSHORT <= 1023) aActFont.SetFamily(FAMILY_SWISS);
         else                      aActFont.SetFamily(FAMILY_ROMAN);
         aActFont.SetCharSet(GetTextEncoding(nUSHORT));
-        pPict->ReadChar( nByteLen ); 
nLen=static_cast<sal_uInt16>(nByteLen)&0x00ff;
-        pPict->ReadBytes(&sFName, nLen);
-        sFName[ nLen ] = 0;
+        char nByteLen(0);
+        pPict->ReadChar( nByteLen );
+        sal_uInt16 nLen = static_cast<sal_uInt16>(nByteLen)&0x00ff;
+        char sFName[ 256 ];
+        sFName[pPict->ReadBytes(sFName, nLen)] = 0;
         OUString aString( sFName, strlen(sFName), osl_getThreadTextEncoding() 
);
         aActFont.SetFamilyName( aString );
         eActMethod = PictDrawingMethod::UNDEFINED;

Reply via email to