summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2014-02-25 14:16:25 +0200
committerCaolán McNamara <caolanm@redhat.com>2014-02-25 16:23:32 +0000
commit27c3b8bca22353dfdcf4c248539a727522fc4e76 (patch)
tree6e56d23130f59cb7c5c41012bc81578f205426d5 /starmath
parentb8ebdae0345aa331cf6d6dabf40a6f26dc7d2371 (diff)
Don't write compound header to zero length files
Change-Id: Ie964ca8b870714d1c3e92469a771fab9a71f0633 Reviewed-on: https://gerrit.libreoffice.org/8220 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/smdetect.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx
index d25f0dd54654..3d23031d8d8e 100644
--- a/starmath/source/smdetect.cxx
+++ b/starmath/source/smdetect.cxx
@@ -296,7 +296,20 @@ 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();
- if (pStrm && !pStrm->GetError())
+
+ sal_Size nSize = 0;
+ if ( pStrm && !pStrm->GetError() )
+ {
+ pStrm->Seek( STREAM_SEEK_TO_END );
+ nSize = pStrm->Tell();
+ pStrm->Seek( STREAM_SEEK_TO_BEGIN );
+ }
+
+ // Do not attempt to create an SotStorage on a
+ // 0-length stream as that would create the compound
+ // document header on the stream and effectively write to
+ // disk!
+ if ( nSize > 0 )
{
SotStorageRef aStorage = new SotStorage ( pStrm, false );
if ( !aStorage->GetError() )