fix: crash on empty dialog extensions array on Windows (#48659)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
a8372e0e70
commit
45aa5396a9
1 changed files with 11 additions and 7 deletions
|
|
@ -44,8 +44,7 @@ void ConvertFilters(const Filters& filters,
|
||||||
std::vector<std::wstring>* buffer,
|
std::vector<std::wstring>* buffer,
|
||||||
std::vector<COMDLG_FILTERSPEC>* filterspec) {
|
std::vector<COMDLG_FILTERSPEC>* filterspec) {
|
||||||
if (filters.empty()) {
|
if (filters.empty()) {
|
||||||
COMDLG_FILTERSPEC spec = {L"All Files (*.*)", L"*.*"};
|
filterspec->push_back({L"All Files (*.*)", L"*.*"});
|
||||||
filterspec->push_back(spec);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,11 +54,16 @@ void ConvertFilters(const Filters& filters,
|
||||||
buffer->push_back(base::UTF8ToWide(filter.first));
|
buffer->push_back(base::UTF8ToWide(filter.first));
|
||||||
spec.pszName = buffer->back().c_str();
|
spec.pszName = buffer->back().c_str();
|
||||||
|
|
||||||
|
if (filter.second.empty()) {
|
||||||
|
buffer->push_back(L"*.*");
|
||||||
|
spec.pszSpec = buffer->back().c_str();
|
||||||
|
} else {
|
||||||
std::vector<std::string> extensions(filter.second);
|
std::vector<std::string> extensions(filter.second);
|
||||||
for (std::string& extension : extensions)
|
for (std::string& extension : extensions)
|
||||||
extension.insert(0, "*.");
|
extension.insert(0, "*.");
|
||||||
buffer->push_back(base::UTF8ToWide(base::JoinString(extensions, ";")));
|
buffer->push_back(base::UTF8ToWide(base::JoinString(extensions, ";")));
|
||||||
spec.pszSpec = buffer->back().c_str();
|
spec.pszSpec = buffer->back().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
filterspec->push_back(spec);
|
filterspec->push_back(spec);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue