Opt++;
for (A = ArgList; A->end() == false &&
- stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++);
+ (A->LongOpt == 0 || stringcasecmp(Opt,OptEnd,A->LongOpt) != 0);
+ ++A);
// Failed again..
if (A->end() == true && OptEnd - Opt != 1)
* apt-pkg/contrib/cmdline.cc:
- apply patch from Daniel Hartwig to fix a segfault in case
the LongOpt is empty (Closes: #676331)
+ - fix segfault with empty LongOpt in --no-* branch
[ Justin B Rye ]
* doc/apt-cdrom.8.xml:
{ 'z', "zero", "Test::Zero", 0 },
{0,0,0,0}
};
-
CommandLine CmdL(Args,_config);
+
char const * argv[] = { "test", "--zero", "-t" };
CmdL.Parse(3 , argv);
-
equals(true, _config->FindB("Test::Worked", false));
equals(true, _config->FindB("Test::Zero", false));
+ _config->Clear("Test");
+ equals(false, _config->FindB("Test::Worked", false));
+ equals(false, _config->FindB("Test::Zero", false));
+
+ _config->Set("Test::Zero", true);
+ equals(true, _config->FindB("Test::Zero", false));
+
+ char const * argv2[] = { "test", "--no-zero", "-t" };
+ CmdL.Parse(3 , argv2);
+ equals(true, _config->FindB("Test::Worked", false));
+ equals(false, _config->FindB("Test::Zero", false));
+
return 0;
}