Avoid buffer overflow by replacing the pointer interface with an array reference interface in C++2a.
Tentatively ready on Batavia2018.
Details
Diff Detail
- Repository
- rCXX libc++
Event Timeline
include/istream | ||
---|---|---|
601 | Should this instead be if (__n == 0)? Can width() ever return a negative number? cppreference says this about streamsize:
I couldn't find a matching statement in the standard, however there's this footnote in 30.5.2:
This does not clearly say that negative values are never used, but it does suggest it. Maybe it's safer to still use __n <= 0. |
Done.
include/istream | ||
---|---|---|
601 | My interpretation of 27.5.3.2 is that you can retrieve the value you set through width(streamsize). And the wording here (unmodified) says "If width() is greater than zero, [...]," so the opposite should be width() <= 0. |
Should this instead be if (__n == 0)? Can width() ever return a negative number? cppreference says this about streamsize:
I couldn't find a matching statement in the standard, however there's this footnote in 30.5.2:
This does not clearly say that negative values are never used, but it does suggest it. Maybe it's safer to still use __n <= 0.