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

std::string::replace (size_type, size_type, size_type, char_type) doesn't check third argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.1.3, 4.1.4, 4.2.0, 4.2.1
    • 4.2.2
    • 21. Strings
    • None
    • All

    • Incorrect Behavior

    Description

      The following test fails with segmentation fault:

      #include <iostream>
      #include <string>
      #include <stdexcept>
      
      static char long_string [4096] = {'a'};
      
      int main ()
      {
          try {
              std::string s (long_string, 4095);
              s.replace (0, 1, s.max_size () + 1, 'a');
              std::cout << "Expect length error, got nothing" << '\n';
          }
          catch (std::length_error& e) {
              std::cout << "Got expected length error" << '\n';
          }
      
          return 0;
      }
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 1h
                  1h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h