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

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.3, 4.1.4, 4.2.0, 4.2.1
    • Fix Version/s: 4.2.2
    • Component/s: 21. Strings
    • Labels:
      None
    • Environment:

      All

    • Severity:
      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

              • Assignee:
                farid Farid Zaripov
                Reporter:
                farid Farid Zaripov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 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