summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-08-08 04:52:28 +0200
committerCaolán McNamara <caolanm@redhat.com>2016-08-08 09:03:13 +0000
commit8452bef1c2cc7585582875fd3216ed4003b817cc (patch)
treeec0baee4696183f9a88f629e25e679c9b0abf4af
parentb7d7089392881575f0332bef4d6b1f4ed10537bc (diff)
don't try to memcpy from and to a nullptr
See e.g. http://crashreport.libreoffice.org/stats/crash_details/2218a489-b64c-4193-a7d4-cd01c6a607cb Change-Id: I6c123d3e9e5c6dbcb7756a686503904cbfd944a4 Reviewed-on: https://gerrit.libreoffice.org/27948 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit 855df248c8a380e253a35feefec21ebc1dee1aca) Reviewed-on: https://gerrit.libreoffice.org/27978 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/filter/GraphicNativeMetadata.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/vcl/source/filter/GraphicNativeMetadata.cxx b/vcl/source/filter/GraphicNativeMetadata.cxx
index 532e2d4284ab..89045776b3c8 100644
--- a/vcl/source/filter/GraphicNativeMetadata.cxx
+++ b/vcl/source/filter/GraphicNativeMetadata.cxx
@@ -37,7 +37,11 @@ bool GraphicNativeMetadata::read(Graphic& rGraphic)
GfxLink aLink = rGraphic.GetLink();
if ( aLink.GetType() != GFX_LINK_TYPE_NATIVE_JPG )
return false;
+
sal_uInt32 aDataSize = aLink.GetDataSize();
+ if (!aDataSize)
+ return false;
+
std::unique_ptr<sal_uInt8[]> aBuffer(new sal_uInt8[aDataSize]);
memcpy(aBuffer.get(), aLink.GetData(), aDataSize);