summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui/scuiasciiopt.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-12-19 17:33:29 +0100
committerEike Rathke <erack@redhat.com>2013-12-19 17:35:55 +0100
commitd340d3bbcf12729adb2cd3a847bc474e3d58b286 (patch)
treef9bddaaa7220412eea4d19df7fc6c531ac5a64c0 /sc/source/ui/dbgui/scuiasciiopt.cxx
parente500b25b08fdab927b987949139588c198edc40b (diff)
check string length of file name before attempting to copy
File names CAN be shorter than 4 characters if they don't have a 3 character file name extension and the filter was selected. Change-Id: Ic25bdf44cd44d48313c748525e75318e05240e8e
Diffstat (limited to 'sc/source/ui/dbgui/scuiasciiopt.cxx')
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx14
1 files changed, 9 insertions, 5 deletions
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 1cd49d613760..6ecdcf61f1d9 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -292,11 +292,15 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,OUString aDatName,
bool bIsCSV = false;
bool bIsTSV = false;
- OUString aExtWithDot = aDatName.copy(aDatName.getLength() - 4); // All handled extensions (csv, tsv, tab) have length of 3
- if ( aExtWithDot.equalsIgnoreAsciiCase(".tsv") || aExtWithDot.equalsIgnoreAsciiCase(".tab") )
- bIsTSV = true;
- else if ( aExtWithDot.equalsIgnoreAsciiCase(".csv") )
- bIsCSV = true;
+ if (aDatName.getLength() >= 4)
+ {
+ // All handled extensions (csv, tsv, tab) have length of 3
+ OUString aExtWithDot = aDatName.copy(aDatName.getLength() - 4);
+ if ( aExtWithDot.equalsIgnoreAsciiCase(".tsv") || aExtWithDot.equalsIgnoreAsciiCase(".tab") )
+ bIsTSV = true;
+ else if ( aExtWithDot.equalsIgnoreAsciiCase(".csv") )
+ bIsCSV = true;
+ }
// Default options are set in officecfg/registry/schema/org/openoffice/Office/Calc.xcs
OUString sFieldSeparators(",;\t");