Menu

#38 string exception with short app name

1.4.x
closed-fixed
None
5
2022-03-03
2022-03-02
No

CmdLineOutput.h helper function basename may throw a string exception when the string length is less than 4.
My fix:
diff --git a/src/tclap/CmdLineOutput.h b/src/tclap/CmdLineOutput.h
index dce8e50..1d5b6bc 100644
--- a/src/tclap/CmdLineOutput.h
+++ b/src/tclap/CmdLineOutput.h
@@ -99,7 +99,7 @@ inline std::string basename(std::string s) {
}

 p = s.rfind(".exe");
  • if (p == s.length() - 4) {
  • if (p != std::string::npos && p == s.length() - 4) {
    s.erase(s.length() - 4);
    }

Discussion

  • Daniel Aarno

    Daniel Aarno - 2022-03-02

    I believe this was fixed about a year ago in [57a98f01bc2ac69812c703df4a99f060240c7214]. Can you try fetching the latest version and see if that fixes the problem?

     

    Related

    Commit: [57a98f]

  • Daniel Aarno

    Daniel Aarno - 2022-03-02
    • status: open --> pending
    • assigned_to: Daniel Aarno
     
  • David Okamoto

    David Okamoto - 2022-03-02

    Yes, it's fixed in that commit.

     
  • Daniel Aarno

    Daniel Aarno - 2022-03-03
    • status: pending --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB