[all-commits] [llvm/llvm-project] 158604: [libc++] Fix basic_string not allowing max_size() ...

Nikolas Klauser via All-commits all-commits at lists.llvm.org
Sun Feb 23 10:02:35 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 15860446a8c3db5c39f92bb371236778e8b00fb0
      https://github.com/llvm/llvm-project/commit/15860446a8c3db5c39f92bb371236778e8b00fb0
  Author: Nikolas Klauser <nikolasklauser at berlin.de>
  Date:   2025-02-23 (Sun, 23 Feb 2025)

  Changed paths:
    M libcxx/include/string
    M libcxx/test/libcxx/strings/basic.string/string.capacity/max_size.pass.cpp
    M libcxx/test/std/strings/basic.string/string.capacity/max_size.pass.cpp
    M libcxx/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
    M libcxx/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp
    M libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
    M libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp
    M libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
    M libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp
    M libcxx/test/std/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp
    M libcxx/test/support/min_allocator.h

  Log Message:
  -----------
  [libc++] Fix basic_string not allowing max_size() elements to be stored (#125423)

Without this patch `basic_string` cannot be properly resized to be
`max_size()` elements in size, even if an allocation is successful.
`__grow_by` allocates one less element than required, resulting in an
out-of-bounds access. At the same time, `max_size()` has an off-by-one
error, since there has to be space to store the null terminator, which
is currently ignored.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list