ENH: fix crashes when command line arguments are not followed by the correct number of arguments
This commit is contained in:
parent
6580114309
commit
ed981ef0b7
|
@ -267,7 +267,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
||||||
std::string entry = arg.substr(2);
|
std::string entry = arg.substr(2);
|
||||||
if(entry.size() == 0)
|
if(entry.size() == 0)
|
||||||
{
|
{
|
||||||
entry = args[++i];
|
++i;
|
||||||
|
if(i < args.size())
|
||||||
|
{
|
||||||
|
entry = args[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("-D must be followed with VAR=VALUE.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::string var, value;
|
std::string var, value;
|
||||||
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
|
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
|
||||||
|
@ -291,7 +300,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
||||||
std::string path = arg.substr(2);
|
std::string path = arg.substr(2);
|
||||||
if ( path.size() == 0 )
|
if ( path.size() == 0 )
|
||||||
{
|
{
|
||||||
path = args[++i];
|
++i;
|
||||||
|
if(i < args.size())
|
||||||
|
{
|
||||||
|
path = args[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("-C must be followed by a file name.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::cerr << "loading initial cache file " << path.c_str() << "\n";
|
std::cerr << "loading initial cache file " << path.c_str() << "\n";
|
||||||
this->ReadListFile(path.c_str());
|
this->ReadListFile(path.c_str());
|
||||||
|
@ -299,6 +317,11 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
|
||||||
else if(arg.find("-P",0) == 0)
|
else if(arg.find("-P",0) == 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
if(i >= args.size())
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("-P must be followed by a file name.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
std::string path = args[i];
|
std::string path = args[i];
|
||||||
if ( path.size() == 0 )
|
if ( path.size() == 0 )
|
||||||
{
|
{
|
||||||
|
@ -425,7 +448,13 @@ void cmake::SetArgs(const std::vector<std::string>& args)
|
||||||
std::string value = arg.substr(2);
|
std::string value = arg.substr(2);
|
||||||
if(value.size() == 0)
|
if(value.size() == 0)
|
||||||
{
|
{
|
||||||
value = args[++i];
|
++i;
|
||||||
|
if(i >= args.size())
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("No generator specified for -G");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
value = args[i];
|
||||||
}
|
}
|
||||||
cmGlobalGenerator* gen =
|
cmGlobalGenerator* gen =
|
||||||
this->CreateGlobalGenerator(value.c_str());
|
this->CreateGlobalGenerator(value.c_str());
|
||||||
|
|
|
@ -236,11 +236,14 @@ int do_cmake(int ac, char** av)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("No script specified for argument -P");
|
cmSystemTools::Error("No script specified for argument -P");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
script_mode = true;
|
script_mode = true;
|
||||||
args.push_back(av[i]);
|
args.push_back(av[i]);
|
||||||
i++;
|
i++;
|
||||||
args.push_back(av[i]);
|
args.push_back(av[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.push_back(av[i]);
|
args.push_back(av[i]);
|
||||||
|
|
Loading…
Reference in New Issue