From 4089083f32a22e7f308b82b9e8dc4a4abaee8b24 Mon Sep 17 00:00:00 2001 From: Ariel Constenla-Haile Date: Fri, 25 Oct 2013 12:49:16 +0000 Subject: Resolves: #i123544# Prevent accessing empty filters' vector (cherry picked from commit 3b16c98449d120b07ca4f2f312e31127ac655482) Change-Id: Ieb71209d9c299ef7f050e00ccf010aca87ee2ab7 --- fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'fpicker') diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx index b6def5b23b12..1e5f9cd61bcf 100644 --- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx @@ -899,15 +899,18 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest) { UINT nFileType; hResult = iDialog->GetFileTypeIndex(&nFileType); - if ( SUCCEEDED(hResult) ) + if ( SUCCEEDED(hResult) && nFileType > 0 ) { ::sal_Int32 nRealIndex = (nFileType-1); // COM dialog base on 1 ... filter container on 0 .-) ::std::vector< COMDLG_FILTERSPEC > lFilters = lcl_buildFilterList(m_lFilters); - LPCWSTR lpFilterExt = lFilters[nRealIndex].pszSpec; + if ( nRealIndex < lFilters.size() ) + { + LPCWSTR lpFilterExt = lFilters[nRealIndex].pszSpec; - lpFilterExt = wcsrchr( lpFilterExt, '.' ); - if ( lpFilterExt ) - aFileURL += reinterpret_cast(lpFilterExt); + lpFilterExt = wcsrchr( lpFilterExt, '.' ); + if ( lpFilterExt ) + aFileURL += reinterpret_cast(lpFilterExt); + } } } -- cgit