From 70c5401aa3b063d0f275042a48a54f42c1f54c03 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Mon, 14 Jul 2014 23:55:04 +0300 Subject: [PATCH 017/137] fdo#81284 Don't write to zero length files Change-Id: I4eddcda3977f43b39abdaa8d9089ff661092361c Reviewed-on: https://gerrit.libreoffice.org/10310 Reviewed-by: David Tardon Tested-by: David Tardon --- sd/source/ui/unoidl/sddetect.cxx | 6 ++++++ starmath/source/smdetect.cxx | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/sd/source/ui/unoidl/sddetect.cxx b/sd/source/ui/unoidl/sddetect.cxx index e8ee02e..161d11f 100644 --- a/sd/source/ui/unoidl/sddetect.cxx +++ b/sd/source/ui/unoidl/sddetect.cxx @@ -351,6 +351,12 @@ OUString SAL_CALL SdFilterDetect::detect( Sequence< beans::PropertyValue >& lDes pStm = aMedium.GetInStream(); if (!pStm) pFilter = NULL; + else + { + pStm->Seek( STREAM_SEEK_TO_BEGIN ); + if (pStm->remainingSize() == 0) + pFilter = NULL; + } } if (pFilter && pStm) diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx index ca9453a..c943bee 100644 --- a/starmath/source/smdetect.cxx +++ b/starmath/source/smdetect.cxx @@ -296,8 +296,16 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor //this approach, to be fixed at a better level than here SvStream *pStrm = aMedium.GetInStream(); aTypeName = OUString(); + + sal_Size nStreamSize = 0; if (pStrm && !pStrm->GetError()) { + pStrm->Seek( STREAM_SEEK_TO_BEGIN ); + nStreamSize = pStrm->remainingSize(); + } + + if ( nStreamSize > 0 ) + { SotStorageRef aStorage = new SotStorage ( pStrm, sal_False ); if ( !aStorage->GetError() ) { -- 1.9.3