From 67f357723929db08736877a4cd7f844d664d2646 Mon Sep 17 00:00:00 2001 From: Simon Date: Wed, 9 May 2018 21:52:33 -0700 Subject: [PATCH] Closes #3250. Memo getter should return by reference, not by value. --- src/gtest/test_joinsplit.cpp | 4 ++++ src/zcash/Note.hpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index dfde47c69..a713fe7dd 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -550,6 +550,10 @@ TEST(joinsplit, note_plaintexts) ASSERT_TRUE(decrypted.memo() == note_pt.memo()); + // Check memo() returns by reference, not return by value, for use cases such as: + // std::string data(plaintext.memo().begin(), plaintext.memo().end()); + ASSERT_TRUE(decrypted.memo().data() == decrypted.memo().data()); + // Check serialization of note plaintext CDataStream ss(SER_DISK, PROTOCOL_VERSION); ss << note_pt; diff --git a/src/zcash/Note.hpp b/src/zcash/Note.hpp index 8254717bb..7c7f0c561 100644 --- a/src/zcash/Note.hpp +++ b/src/zcash/Note.hpp @@ -49,7 +49,7 @@ public: virtual ~BaseNotePlaintext() {} inline uint64_t value() const { return value_; } - inline boost::array memo() const { return memo_; } + inline const boost::array & memo() const { return memo_; } }; class SproutNotePlaintext : public BaseNotePlaintext {