Skip to content

Commit

Permalink
Bug fix causing a core dump in command line options parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Jay Rush committed Jun 24, 2017
1 parent 63d4cc9 commit 81fb262
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libs/utillib/options_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ namespace qblocks {
if ((SFUint32)argc <= minArgs) // the first arg is the program's name
return usage("Not enough arguments presented.");

int nChars = 0;
for (int i=0; i<argc; i++) {
nChars += SFString(argv[i]).length();
}
uint32_t nArgs = 0;
SFString *args = new SFString[argc+2];
SFString *args = new SFString[argc+nChars+2];

bool hasStdIn = false;
for (int i = 1 ; i < argc ; i++) {
Expand Down Expand Up @@ -155,6 +159,12 @@ namespace qblocks {
shortName += name[0];
longName = "-" + name;
}
if (longName.Contains("(") && longName.Contains(")")) {
hotKey = longName;
nextTokenClear(hotKey,'(');
hotKey = nextTokenClear(hotKey, ')');
longName.ReplaceAny("()","");
}
}
}

Expand Down

0 comments on commit 81fb262

Please sign in to comment.