mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-16 09:51:56 +00:00
Check accesses to the bookname_to_ifo std::map
Avoid crashes when passing unknown dicts to the -u flag Fix #87
This commit is contained in:
committed by
Evgeniy Dushistov
parent
488ec68854
commit
abe5e9e72f
14
src/sdcv.cpp
14
src/sdcv.cpp
@@ -186,10 +186,11 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add bookname to list
|
// add bookname to list
|
||||||
gchar **p = get_impl(use_dict_list);
|
for (gchar **p = get_impl(use_dict_list); *p != nullptr; ++p) {
|
||||||
while (*p) {
|
auto it = bookname_to_ifo.find(*p);
|
||||||
order_list.push_back(bookname_to_ifo.at(*p));
|
if (it != bookname_to_ifo.end()) {
|
||||||
++p;
|
order_list.push_back(it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string ordering_cfg_file = std::string(g_get_user_config_dir()) + G_DIR_SEPARATOR_S "sdcv_ordering";
|
std::string ordering_cfg_file = std::string(g_get_user_config_dir()) + G_DIR_SEPARATOR_S "sdcv_ordering";
|
||||||
@@ -201,7 +202,10 @@ try {
|
|||||||
if (ordering_file != nullptr) {
|
if (ordering_file != nullptr) {
|
||||||
std::string line;
|
std::string line;
|
||||||
while (stdio_getline(ordering_file, line)) {
|
while (stdio_getline(ordering_file, line)) {
|
||||||
order_list.push_back(bookname_to_ifo.at(line));
|
auto it = bookname_to_ifo.find(line);
|
||||||
|
if (it != bookname_to_ifo.end()) {
|
||||||
|
order_list.push_back(it->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose(ordering_file);
|
fclose(ordering_file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user