Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-175

std::string::replace (size_type, size_type, const_pointer, size_type) doesn't check last argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.1.3
    • None
    • 21. Strings
    • None
    • all

    Description

      The following test fails with segmentation fault:

      #include <iostream>
      #include <string>
      #include <stdexcept>

      static char long_string [4096] =

      {'a'}

      ;

      int main (void)
      {
      try

      { std::string s (long_string, 4095); s.replace (0, 1, "a", s.max_size () + 1); std::cout << "Expect length error, got nothing" << '\n'; }

      catch (std::length_error& e)

      { std::cout << "Got expected length error" << '\n'; }

      return 0;
      }

      See the discussion for additional details:
      http://mail-archives.apache.org/mod_mbox/incubator-stdcxx-dev/200604.mbox/%3c444EC747.1090200@roguewave.com%3e

      Attachments

        Issue Links

          Activity

            People

              farid Farid Zaripov
              pevtsov Anton Pevtsov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: