Page MenuHomePhabricator

[backport#17280] refactor: Change occurences of c_str() used with size() to data()
ClosedPublic

Authored by majcosta on Sep 7 2020, 22:13.

Details

Summary

Fix occurences of c_str() used with size() to data() (Wladimir J. van der Laan)

Pull request description:

Using `data()` better communicates the intent here.

~~Also, depending on how `c_str()` is implemented, this fixes undefined behavior: The part of the string after the first NULL character might have undefined contents (or even be inaccessible, worst case).~~ Apparently [this is no longer an issue with C++11](https://github.com/bitcoin/bitcoin/pull/17281#discussion_r339742128).

Backport of Core PR17280

Test Plan
ninja check check-functional

Diff Detail

Event Timeline

majcosta requested review of this revision.Sep 7 2020, 22:13

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

deadalnix requested changes to this revision.Sep 8 2020, 03:43
deadalnix added a subscriber: deadalnix.

You need to get src/crypto/hkdf_sha256_32.cpp first.

This revision now requires changes to proceed.Sep 8 2020, 03:43
This revision is now accepted and ready to land.Sep 8 2020, 22:31