summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2006-05-19 03:24:00 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2006-05-19 03:24:00 (GMT)
commited981ef0b7f6988e205ad540bc82581b9f0a7f0b (patch)
treeaee8f51261c13ec153ba8103a2f6a46d6bad2732 /Source/cmake.cxx
parent6580114309dd2a0e547ddf9b8cb4148fe6cc857f (diff)
downloadCMake-ed981ef0b7f6988e205ad540bc82581b9f0a7f0b.zip
CMake-ed981ef0b7f6988e205ad540bc82581b9f0a7f0b.tar.gz
CMake-ed981ef0b7f6988e205ad540bc82581b9f0a7f0b.tar.bz2
ENH: fix crashes when command line arguments are not followed by the correct number of arguments
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx35
1 files changed, 32 insertions, 3 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 84ecc0f..f037fc3 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -267,7 +267,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
std::string entry = arg.substr(2);
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;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
@@ -291,7 +300,16 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
std::string path = arg.substr(2);
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";
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)
{
i++;
+ if(i >= args.size())
+ {
+ cmSystemTools::Error("-P must be followed by a file name.");
+ return false;
+ }
std::string path = args[i];
if ( path.size() == 0 )
{
@@ -425,7 +448,13 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::string value = arg.substr(2);
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 =
this->CreateGlobalGenerator(value.c_str());