Multiple ChoiceIntermediate 45s
string_view not null-terminated
Why can passing `sv.data()` from a non-null-terminated `std::string_view` to a C API be a bug?
Options
- 1data() always returns nullptr for any view, so the C API would dereference a null pointer.
- 2The C API always copies the bytes it reads into its own buffer, so it cannot overrun.
- 3The view is a pointer+length and is not guaranteed to be null-terminated, so the C function may read past the end.
- 4string_view inserts a null terminator into the buffer automatically when data() is called.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.