diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-08 20:29:41 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-08 22:28:31 +0200 |
commit | 5b6fcbf4a754a2699b3b865256848238f93113a2 (patch) | |
tree | 4331ab95144853a947266dceead330b846c36452 /emfio | |
parent | c07f4a7d04eb44020045859d305f4510ae9acfc4 (diff) |
ofz: MemorySanitizer: use-of-uninitialized-value
sidestep the resize behaviour of SvMemoryStream by using an honest
std::vector and make it use that buffer
Change-Id: Ic5e405010ac076fc04e1ca8dc6dbb495162101ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121832
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'emfio')
-rw-r--r-- | emfio/inc/wmfreader.hxx | 2 | ||||
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/emfio/inc/wmfreader.hxx b/emfio/inc/wmfreader.hxx index a7dff2b94d85..f7788d53651c 100644 --- a/emfio/inc/wmfreader.hxx +++ b/emfio/inc/wmfreader.hxx @@ -35,7 +35,7 @@ namespace emfio sal_uInt32 mnRecSize; // embedded EMF data - std::unique_ptr<SvMemoryStream> mpEMFStream; + std::optional<std::vector<sal_uInt8>> mpEMFStream; // total number of comment records containing EMF data sal_uInt32 mnEMFRecCount; diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index a32c7f100e04..d71dbf485710 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1315,7 +1315,7 @@ namespace emfio mpEMFStream.reset(); } else - mpEMFStream = std::make_unique<SvMemoryStream>(mnEMFSize, 0); + mpEMFStream = std::vector<sal_uInt8>(); } else if( (mnEMFRecCount != nComRecCount ) || (mnEMFSize != nEMFTotalSize ) ) // add additional checks here { @@ -1343,7 +1343,9 @@ namespace emfio std::vector<sal_Int8> aBuf(nCurRecSize); sal_uInt32 nCount = mpInputStream->ReadBytes(aBuf.data(), nCurRecSize); if( nCount == nCurRecSize ) - mpEMFStream->WriteBytes(aBuf.data(), nCount); + { + mpEMFStream->insert(mpEMFStream->end(), aBuf.begin(), aBuf.end()); + } } } } @@ -1594,8 +1596,8 @@ namespace emfio if(mpEMFStream && mnEMFRecCount == mnEMFRec) { GDIMetaFile aMeta; - mpEMFStream->Seek( 0 ); - std::unique_ptr<EmfReader> pEMFReader(std::make_unique<EmfReader>( *mpEMFStream, aMeta )); + SvMemoryStream aStream(mpEMFStream->data(), mpEMFStream->size(), StreamMode::STD_READ); + std::unique_ptr<EmfReader> pEMFReader(std::make_unique<EmfReader>(aStream, aMeta)); pEMFReader->SetEnableEMFPlus(mbEnableEMFPlus); bEMFAvailable = pEMFReader->ReadEnhWMF(); pEMFReader.reset(); // destroy first!!! |