aboutsummaryrefslogtreecommitdiff
path: root/src/mnemonics
diff options
context:
space:
mode:
authorOran Juice <oranjuices@hotmail.com>2014-09-27 00:55:21 +0530
committerOran Juice <oranjuices@hotmail.com>2014-09-27 00:55:21 +0530
commit262e155bab392783b4b282e3abc2d0934e196b56 (patch)
treef9403681c82db34c21e2ae8adb20e3e6936cc090 /src/mnemonics
parentSupports wallet restoration (diff)
downloadmonero-262e155bab392783b4b282e3abc2d0934e196b56.tar.xz
Throw error when word list file is empty and quick bug fix
Diffstat (limited to 'src/mnemonics')
-rw-r--r--src/mnemonics/electrum-words.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mnemonics/electrum-words.cpp b/src/mnemonics/electrum-words.cpp
index 251503d9b..3ef7c5efc 100644
--- a/src/mnemonics/electrum-words.cpp
+++ b/src/mnemonics/electrum-words.cpp
@@ -63,6 +63,7 @@ namespace
{
words_array.clear();
words_map.clear();
+ num_words = 0;
std::ifstream input_stream;
input_stream.open(word_file.c_str(), std::ifstream::in);
@@ -109,8 +110,8 @@ namespace crypto
}
if (num_words == 0)
{
- throw std::runtime_error(std::string("Word list file is corrupt: ") +
- old_word_list ? OLD_WORD_FILE : (LANGUAGES_DIRECTORY + '/' + language));
+ throw std::runtime_error(std::string("Word list file is empty: ") +
+ (old_word_list ? OLD_WORD_FILE : (LANGUAGES_DIRECTORY + '/' + language)));
}
}
@@ -128,13 +129,16 @@ namespace crypto
boost::split(wlist, words, boost::is_any_of(" "));
std::vector<std::string> languages;
+ get_language_list(languages);
std::vector<std::string>::iterator it;
- get_language_list(languages);
- for (it = languages.begin(); it != languages.end() &&
- !word_list_file_match(wlist); it++)
+ for (it = languages.begin(); it != languages.end(); it++)
{
init(*it);
+ if (word_list_file_match(wlist))
+ {
+ break;
+ }
}
if (it == languages.end())
{