Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...)

This commit is contained in:
practicalswift committed 2019-02-07 22:30:25 +01:00
1 parent 1933e38c1a
commit d855e4cac8
2 files changed
+3 -2

No files matched your search

+3 -1
View File
@@ -142,7 +142,9 @@ CKey DecodeSecret(const std::string& str)
key.Set(data.begin() + privkey_prefix.size(), data.begin() + privkey_prefix.size() + 32, compressed);
}
}
memory_cleanse(data.data(), data.size());
if (!data.empty()) {
memory_cleanse(data.data(), data.size());
}
return key;
}