aboutsummaryrefslogtreecommitdiff
path: root/src/span.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-07-26 19:01:48 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-07-26 19:01:51 +0200
commit31d2b4098a9e4ee9a694ba1ad42829637cbcf3c6 (patch)
tree04a7cc70602a5cd9b717fd988299956fd37ba7c8 /src/span.h
parent40a04814d130dfc9131af3f568eb44533e2bcbfc (diff)
parentfa2ae0ac8d43086430a29c73940ad6b1cd129e96 (diff)
downloadbitcoin-31d2b4098a9e4ee9a694ba1ad42829637cbcf3c6.tar.xz
Merge #19508: Work around memory-aliasing in descriptor ParsePubkey
fa2ae0ac8d43086430a29c73940ad6b1cd129e96 span: Add Span::empty() and use it in script/descriptor (MarcoFalke) fa8a99258947a9ee3749fa472180542920cd471c Work around memory-aliasing in descriptor ParsePubkey (MarcoFalke) Pull request description: While this is not undefined behaviour, the memory aliasing trick is confusing when reading the code. Having `a.size()==0` and then access `a[0]` works in this particular case, but should probably be avoided to harden the code for the future. ACKs for top commit: theStack: re-ACK https://github.com/bitcoin/bitcoin/pull/19508/commits/fa2ae0ac8d43086430a29c73940ad6b1cd129e96 elichai: ACK fa2ae0ac8d43086430a29c73940ad6b1cd129e96 jonatack: ACK fa2ae0ac8d43086430a29c73940ad6b1cd129e96 Tree-SHA512: 0ec7b09eef45504973a195923cdf1aa8522117c8e2f69b453e5ce9aa8a7e327c71138518022c32d05133dc99cb861101ed0f60fa891814ee3e9dab3a6fa61a84
Diffstat (limited to 'src/span.h')
-rw-r--r--src/span.h1
1 files changed, 1 insertions, 0 deletions
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);