From fa8a99258947a9ee3749fa472180542920cd471c Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 13 Jul 2020 22:00:40 +0200 Subject: Work around memory-aliasing in descriptor ParsePubkey --- src/script/descriptor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 5fa128d62d..6c5961f60e 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -826,7 +826,8 @@ std::unique_ptr ParsePubkey(uint32_t key_exp_index, const Span Date: Sun, 19 Jul 2020 20:53:08 +0200 Subject: span: Add Span::empty() and use it in script/descriptor --- src/script/descriptor.cpp | 6 +++--- src/span.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 6c5961f60e..9978d084d5 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -825,9 +825,9 @@ std::unique_ptr ParsePubkey(uint32_t key_exp_index, const Span ParseScript(uint32_t key_exp_index, Span 16) { + if (providers.empty() || providers.size() > 16) { error = strprintf("Cannot have %u keys in multisig; must have between 1 and 16 keys, inclusive", providers.size()); return nullptr; } else if (thres < 1) { diff --git a/src/span.h b/src/span.h index 841f1eadf7..79f13c9203 100644 --- a/src/span.h +++ b/src/span.h @@ -151,6 +151,7 @@ public: return m_data[m_size - 1]; } constexpr std::size_t size() const noexcept { return m_size; } + constexpr bool empty() const noexcept { return size() == 0; } CONSTEXPR_IF_NOT_DEBUG C& operator[](std::size_t pos) const noexcept { ASSERT_IF_DEBUG(size() > pos); -- cgit v1.2.3