strlen() returns the length of the string but you must account for the null
terminator yourself. Hence, this code sometimes caused random invalid writes and crashes.
This commit is contained in:
@@ -121,8 +121,8 @@ BOOST_AUTO_TEST_CASE(TestBooleanOption)
|
||||
// Now, if we specify this flag, it should be true.
|
||||
int argc = 2;
|
||||
char* argv[2];
|
||||
argv[0] = strcpy(new char[strlen("programname")], "programname");
|
||||
argv[1] = strcpy(new char[strlen("--flag_test")], "--flag_test");
|
||||
argv[0] = strcpy(new char[strlen("programname") + 1], "programname");
|
||||
argv[1] = strcpy(new char[strlen("--flag_test") + 1], "--flag_test");
|
||||
|
||||
CLI::ParseCommandLine(argc, argv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user