Fixed memory corruption in optionless binaries.
This commit is contained in:
parent
61246062fb
commit
2705af4012
1 changed files with 31 additions and 29 deletions
|
@ -28,7 +28,7 @@ std::string Util::Config::libver = PACKAGE_VERSION;
|
|||
/// Creates a new configuration manager.
|
||||
Util::Config::Config(std::string cmd, std::string version){
|
||||
vals.null();
|
||||
long_count = 0;
|
||||
long_count = 2;
|
||||
vals["cmd"]["value"].append(cmd);
|
||||
vals["version"]["long"] = "version";
|
||||
vals["version"]["short"] = "v";
|
||||
|
@ -173,6 +173,7 @@ void Util::Config::parseArgs(int argc, char ** argv){
|
|||
struct option * longOpts = (struct option*)calloc(long_count + 1, sizeof(struct option));
|
||||
int long_i = 0;
|
||||
int arg_count = 0;
|
||||
if (vals.size()){
|
||||
for (JSON::ObjIter it = vals.ObjBegin(); it != vals.ObjEnd(); it++){
|
||||
if (it->second.isMember("short")){
|
||||
shortopts += it->second["short"].asString();
|
||||
|
@ -208,6 +209,7 @@ void Util::Config::parseArgs(int argc, char ** argv){
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((opt = getopt_long(argc, argv, shortopts.c_str(), longOpts, 0)) != -1){
|
||||
switch (opt){
|
||||
case 'h':
|
||||
|
|
Loading…
Add table
Reference in a new issue