From 3ddf70dc1129e9b2294b582256c657305bbf3b3e Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 5 Jun 2013 21:27:07 +0200 Subject: xmlhelp: fix reading symlinked .tree files Apparently the .tree files nowadays are symlinked, which was not the case on the libreoffice-4-0 branch... and on viewing the Contents tab it's evident we can't actually read symlinked .tree files, and crash with an STL assert because the children vector is empty. Change-Id: I5a543ef85b827e194120530a486cf19a76837d87 --- xmlhelp/source/treeview/tvread.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'xmlhelp') diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx index 8a2d494d4cbe..d96d4a5e98ad 100644 --- a/xmlhelp/source/treeview/tvread.cxx +++ b/xmlhelp/source/treeview/tvread.cxx @@ -546,6 +546,11 @@ TVChildTarget::~TVChildTarget() void TVChildTarget::Check(TVDom* tvDom) { + if (tvDom->children.empty()) + { + return; + } + unsigned i = 0; bool h = false; @@ -808,7 +813,8 @@ ConfigData TVChildTarget::init( const Reference< XComponentContext >& xContext ) } osl::Directory aDirectory( url ); - osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_FileSize | osl_FileStatus_Mask_FileURL ); + osl::FileStatus aFileStatus( + osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_FileURL ); if( osl::Directory::E_None == aDirectory.open() ) { int idx_ = 0; @@ -832,18 +838,17 @@ ConfigData TVChildTarget::init( const Reference< XComponentContext >& xContext ) ( str[idx_ + 3] == 'e' || str[idx_ + 3] == 'E' ) && ( str[idx_ + 4] == 'e' || str[idx_ + 4] == 'E' ) ) { - OSL_ENSURE( aFileStatus.isValid( osl_FileStatus_Mask_FileSize ), - "invalid file size" ); - OUString baseName = aFileName.copy(0,idx_).toAsciiLowerCase(); if(! showBasic && baseName.compareToAscii("sbasic") == 0 ) continue; osl::File aFile( aFileUrl ); if( osl::FileBase::E_None == aFile.open( osl_File_OpenFlag_Read ) ) { + // use the file size, not aFileStatus size, in case the + // tree file is a symlink sal_uInt64 nSize; aFile.getSize( nSize ); - configData.vFileLen.push_back( aFileStatus.getFileSize() ); + configData.vFileLen.push_back( nSize ); configData.vFileURL.push_back( aFileUrl ); aFile.close(); } -- cgit v1.2.3