Skip to content

Commit 500710b

Browse files
committed
Fix 2 subscript[0] bugs in pubkey.cpp, and eliminate one extra size check
1 parent e0451e3 commit 500710b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/pubkey.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchS
172172
if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) {
173173
return false;
174174
}
175-
if (vchSig.size() == 0) {
176-
return false;
177-
}
178-
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) {
175+
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, vchSig.data(), vchSig.size())) {
179176
return false;
180177
}
181178
/* libsecp256k1's ECDSA verification requires lower-S signatures, which have
@@ -274,7 +271,7 @@ bool CExtPubKey::Derive(CExtPubKey &out, unsigned int _nChild) const {
274271

275272
/* static */ bool CPubKey::CheckLowS(const std::vector<unsigned char>& vchSig) {
276273
secp256k1_ecdsa_signature sig;
277-
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) {
274+
if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, vchSig.data(), vchSig.size())) {
278275
return false;
279276
}
280277
return (!secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, NULL, &sig));

0 commit comments

Comments
 (0)