laanwj
commented at 12:51 PM on October 28, 2019:
member
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.
Fix occurences of c_str() used with size() to data()
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.
f3b51eb935
laanwj added the label Bug on Oct 28, 2019
fjahr
commented at 2:25 PM on October 28, 2019:
member
Code review ACKf3b51eb
practicalswift
commented at 2:53 PM on October 28, 2019:
contributor
Concept ACK
What about linting this to make sure this is a one-time fix-up?
laanwj
commented at 3:19 PM on October 28, 2019:
member
What about linting this to make sure this is a one-time fix-up?
Maybe—It could catch some of them, I guess. But only if they're on the same line?
(which is the case for all of these, admittedly)
practicalswift
commented at 3:34 PM on October 28, 2019:
contributor
@laanwj Correct, multi-line search with git grep is not possible AFAIK, so there could be false negatives.
ryanofsky approved
ryanofsky
commented at 4:17 PM on October 28, 2019:
member
Code review ACKf3b51eb9352d7a7c5dfa15615efc8bc0a52ffecf. Most of these calls (including one in crypter.cpp) are passing text strings, not binary strings likely to contain \0 and were probably safe before, but much better to avoid the possibility of bugs like this.
MarcoFalke removed the label Bug on Oct 28, 2019
MarcoFalke added the label Refactoring on Oct 28, 2019
MarcoFalke
commented at 7:37 PM on October 28, 2019:
member
c_str() and data() perform the same function. | (since C++11)
I have removed the "bug" label and added the "Refactoring" label.
Concept ACK, though.
practicalswift
commented at 11:20 AM on October 29, 2019:
contributor
ACKf3b51eb9352d7a7c5dfa15615efc8bc0a52ffecf -- diff looks correct, data() more idiomatic
laanwj renamed this: Fix occurences of c_str() used with size() to data() refactor: Change occurences of c_str() used with size() to data() on Oct 30, 2019
laanwj referenced this in commit 5728f88d64 on Oct 30, 2019
laanwj merged this on Oct 30, 2019
laanwj closed this on Oct 30, 2019
sidhujag referenced this in commit d7a4574b8a on Oct 30, 2019
jasonbcox referenced this in commit 81d108f6f2 on Sep 9, 2020
sidhujag referenced this in commit 401599fe37 on Nov 10, 2020
kittywhiskers referenced this in commit 2c13748489 on May 19, 2021
kittywhiskers referenced this in commit d9489c72af on May 19, 2021
kittywhiskers referenced this in commit bc77b4349a on May 20, 2021
kittywhiskers referenced this in commit 61bfe7b8ab on May 20, 2021
kittywhiskers referenced this in commit 6590f56c43 on May 20, 2021
kittywhiskers referenced this in commit 6a73b70131 on May 20, 2021
PastaPastaPasta referenced this in commit b76e7fec1f on May 21, 2021
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me