Skip to content

Commit 4cac0d1

Browse files
committed
Fix subscript[0] in validation.cpp
1 parent ac658e5 commit 4cac0d1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/serialize.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,15 @@ class LimitedString
450450
}
451451
string.resize(size);
452452
if (size != 0)
453-
s.read((char*)&string[0], size);
453+
s.read((char*)string.data(), size);
454454
}
455455

456456
template<typename Stream>
457457
void Serialize(Stream& s) const
458458
{
459459
WriteCompactSize(s, string.size());
460460
if (!string.empty())
461-
s.write((char*)&string[0], string.size());
461+
s.write((char*)string.data(), string.size());
462462
}
463463
};
464464

@@ -556,7 +556,7 @@ void Serialize(Stream& os, const std::basic_string<C>& str)
556556
{
557557
WriteCompactSize(os, str.size());
558558
if (!str.empty())
559-
os.write((char*)&str[0], str.size() * sizeof(str[0]));
559+
os.write((char*)str.data(), str.size() * sizeof(C));
560560
}
561561

562562
template<typename Stream, typename C>
@@ -565,7 +565,7 @@ void Unserialize(Stream& is, std::basic_string<C>& str)
565565
unsigned int nSize = ReadCompactSize(is);
566566
str.resize(nSize);
567567
if (nSize != 0)
568-
is.read((char*)&str[0], nSize * sizeof(str[0]));
568+
is.read((char*)str.data(), nSize * sizeof(C));
569569
}
570570

571571

@@ -578,7 +578,7 @@ void Serialize_impl(Stream& os, const prevector<N, T>& v, const unsigned char&)
578578
{
579579
WriteCompactSize(os, v.size());
580580
if (!v.empty())
581-
os.write((char*)&v[0], v.size() * sizeof(T));
581+
os.write((char*)v.data(), v.size() * sizeof(T));
582582
}
583583

584584
template<typename Stream, unsigned int N, typename T, typename V>
@@ -646,7 +646,7 @@ void Serialize_impl(Stream& os, const std::vector<T, A>& v, const unsigned char&
646646
{
647647
WriteCompactSize(os, v.size());
648648
if (!v.empty())
649-
os.write((char*)&v[0], v.size() * sizeof(T));
649+
os.write((char*)v.data(), v.size() * sizeof(T));
650650
}
651651

652652
template<typename Stream, typename T, typename A, typename V>

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,7 @@ std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBloc
28902890
if (consensusParams.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0) {
28912891
if (commitpos == -1) {
28922892
uint256 witnessroot = BlockWitnessMerkleRoot(block, NULL);
2893-
CHash256().Write(witnessroot.begin(), 32).Write(&ret[0], 32).Finalize(witnessroot.begin());
2893+
CHash256().Write(witnessroot.begin(), 32).Write(ret.data(), 32).Finalize(witnessroot.begin());
28942894
CTxOut out;
28952895
out.nValue = 0;
28962896
out.scriptPubKey.resize(38);

0 commit comments

Comments
 (0)