HomePhabricator

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

Description

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

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

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7387

Details

Provenance
Wladimir J. van der Laan <laanwj@protonmail.com>Authored on Oct 30 2019, 09:42
majcostaCommitted on Sep 9 2020, 01:22
majcostaPushed on Sep 9 2020, 01:23
Reviewer
Restricted Project
Differential Revision
D7387: [backport#17280] refactor: Change occurences of c_str() used with size() to data()
Parents
rABCddeda021da8c: [backport#14047 4/4] QA: add test for HKDF HMAC_SHA256 L32
Branches
Unknown
Tags
Unknown