aboutsummaryrefslogtreecommitdiff
path: root/src/key_io.cpp
diff options
context:
space:
mode:
authorpracticalswift <practicalswift@users.noreply.github.com>2018-09-17 16:30:08 +0200
committerpracticalswift <practicalswift@users.noreply.github.com>2019-02-07 22:30:25 +0100
commitd855e4cac8303ad4e34ac31cfa7634286589ce99 (patch)
treebb5a0565037d721742410cbbf6b9094fbfec7c11 /src/key_io.cpp
parent1933e38c1a08d479130d11d9fc08bc7c73a82575 (diff)
Avoid triggering undefined behaviour (std::memset(nullptr, 0, 0)) if an invalid string is passed to DecodeSecret(...)
Diffstat (limited to 'src/key_io.cpp')
-rw-r--r--src/key_io.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/key_io.cpp b/src/key_io.cpp
index d998089535..1d53a5e074 100644
--- a/src/key_io.cpp
+++ b/src/key_io.cpp
@@ -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;
}