Skip to content

<regex>: regex_search stack overflow #2807

@segeter

Description

@segeter
static void Test() {
  std::string txt = "\n\n\n\n\n\n"
      "Network Working Group                                       J. Rosenberg\n"
      "Request for Comments: 3261                                   dynamicsoft\n"
      "Obsoletes: 2543                                           H. Schulzrinne\n"
      "Category: Standards Track                                    Columbia U.\n"
      "                                                            G. Camarillo\n"
      "\n";
  std::smatch result;
  std::regex rex("(?:.+\n)+\n");
  while (std::regex_search(txt, result, rex)) {
    for (const auto& str : result) {
      std::cout << str << std::endl;
    }
    txt = result.suffix();
  }
}

int main(int argc, char* argv[]) { Test(); }

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions