[Libreoffice-commits] core.git: emfio/inc emfio/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 8 20:29:06 UTC 2021
emfio/inc/wmfreader.hxx | 2 +-
emfio/source/reader/wmfreader.cxx | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
New commits:
commit 5b6fcbf4a754a2699b3b865256848238f93113a2
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Sep 8 20:29:41 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 8 22:28:31 2021 +0200
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 at redhat.com>
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!!!
More information about the Libreoffice-commits
mailing list