std: Fix std::string push_back()

Allocate 2 bytes if cap == 0, not 1.
This commit is contained in:
EnderIce2 2024-10-15 03:58:17 +03:00
parent ccb2cdde55
commit b31d49be15
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -1530,7 +1530,7 @@ namespace std
constexpr void push_back(CharT ch)
{
if (_size == _capacity)
reserve(_capacity == 0 ? 1 : _capacity * 2);
reserve(_capacity == 0 ? 2 : _capacity * 2);
_data[_size++] = ch;
_data[_size] = 0;