Changeset 1502c05 in mainline


Ignore:
Timestamp:
2023-10-22T13:56:55Z (7 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aaafcc8
Parents:
0eea807
git-author:
Vojtech Horky <vojtech.horky@…> (2023-07-25 13:05:37)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2023-10-22 13:56:55)
Message:

C++ strings: missing space for null terminator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/__bits/string/string.hpp

    r0eea807 r1502c05  
    521521
    522522            basic_string(size_type n, value_type c, const allocator_type& alloc = allocator_type{})
    523                 : data_{}, size_{n}, capacity_{n}, allocator_{alloc}
     523                : data_{}, size_{n}, capacity_{n + 1}, allocator_{alloc}
    524524            {
    525525                data_ = allocator_.allocate(capacity_);
     
    908908            {
    909909                // TODO: if (n > max_size()) throw length_error.
    910                 resize_without_copy_(n);
     910                resize_without_copy_(n + 1);
    911911                traits_type::copy(begin(), str, n);
    912912                size_ = n;
Note: See TracChangeset for help on using the changeset viewer.