]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: check length in string append [PR103534]
authorJason Merrill <jason@redhat.com>
Fri, 10 Dec 2021 16:21:50 +0000 (11:21 -0500)
committerJason Merrill <jason@redhat.com>
Sat, 11 Dec 2021 04:58:13 +0000 (23:58 -0500)
commit2e8067041d1d69da02bd7578f58abc11eb35a04b
tree5b3b28b4f30f602d6f8e96592a560f9803b3e08d
parent0bceef1671adee52e9cc409d82e5f5590fed8d45
libstdc++: check length in string append [PR103534]

In the testcase for 103534 we get a warning about append leading to memcpy
of a very large number of bytes overflowing the buffer.  This turns out to
be because we weren't calling _M_check_length for string append.  Rather
than do that directly, let's go through the public pointer append that calls
it.

PR c++/103534

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (append (basic_string)): Call pointer
append instead of _M_append directly.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wstringop-overflow-8.C: New test.
gcc/testsuite/g++.dg/warn/Wstringop-overflow-8.C [new file with mode: 0644]
libstdc++-v3/include/bits/basic_string.h