summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorJuergen Funk <juergen.funk_ml@cib.de>2017-12-20 13:09:40 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-12-22 16:43:04 +0100
commit26be5f21cebfe9acad088a1086f97eebdb437b7c (patch)
tree2333ea6b01c8a2cd749e5392ad033f2a28157ea5 /unotools
parent1b73ed91e1cce20b3b552a36d449fb96cc57bf4f (diff)
unotools: don't go belly-up if temp dir is wrong or empty
When a wrong temp directory was set (e.g. wrong path in xcu ist set), you get a assert in the LO-Debug Version, this patch avoid this assertion. Change-Id: I192f682860ad9cddf907e4b239eff36b4bd6072d Reviewed-on: https://gerrit.libreoffice.org/46846 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/ucbhelper/tempfile.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index eb099a43dca9..47afc2ed82ce 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -57,13 +57,18 @@ namespace utl
OUString getParentName( const OUString& aFileName )
{
sal_Int32 lastIndex = aFileName.lastIndexOf( '/' );
- OUString aParent = aFileName.copy( 0, lastIndex );
+ OUString aParent;
- if( aParent.endsWith(":") && aParent.getLength() == 6 )
- aParent += "/";
+ if (lastIndex > -1)
+ {
+ aParent = aFileName.copy(0, lastIndex);
+
+ if (aParent.endsWith(":") && aParent.getLength() == 6)
+ aParent += "/";
- if( aParent.equalsIgnoreAsciiCase( "file://" ) )
- aParent = "file:///";
+ if (aParent.equalsIgnoreAsciiCase("file://"))
+ aParent = "file:///";
+ }
return aParent;
}