Merge #10961: Improve readability of DecodeBase58Check(...)

c6a995e Improve readability of DecodeBase58Check(...) (practicalswift)

Pull request description:

  Use the more readable form ...

  ```c++
  &vchRet[vchRet.size() - 4]
  ```

  ... instead of ...

  ```c++
  &v.end()[-n]
  ```

  Has the added benefit of eliminating a spurious static analyzer warning about improper use of negative values.

Tree-SHA512: 5895310c189e9322082c28f34342ff9a6c238e2cae3f204521111c8a7981bc555af60b42de082c91608c1125dfc244a65c4faf929249a067a51435e2be74cb39
This commit is contained in:
Wladimir J. van der Laan 2017-10-09 16:40:36 +02:00
commit da0478e6e5
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -139,7 +139,7 @@ bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet)
} }
// re-calculate the checksum, ensure it matches the included 4-byte checksum // re-calculate the checksum, ensure it matches the included 4-byte checksum
uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4); uint256 hash = Hash(vchRet.begin(), vchRet.end() - 4);
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) { if (memcmp(&hash, &vchRet[vchRet.size() - 4], 4) != 0) {
vchRet.clear(); vchRet.clear();
return false; return false;
} }