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

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.3
    • Fix Version/s: None
    • Component/s: 21. Strings
    • Labels:
      None
    • Environment:

      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: