summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-03-12 23:24:27 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-03-12 23:24:27 (GMT)
commit3fe6b3ce370ea8916987b4115ca7c0bf72f831b9 (patch)
tree5da50ae171c82524bf9da42218423bd6bd2f510b /Source
parent5174fbd39079e6cb3b43599e6ee234d9e550201a (diff)
downloadCMake-3fe6b3ce370ea8916987b4115ca7c0bf72f831b9.zip
CMake-3fe6b3ce370ea8916987b4115ca7c0bf72f831b9.tar.gz
CMake-3fe6b3ce370ea8916987b4115ca7c0bf72f831b9.tar.bz2
BUG: fix #8704, sometimes crash if include_directories() is called with a whitespace string
Alex
Diffstat (limited to 'Source')
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx19
1 files changed, 7 insertions, 12 deletions
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index 1c8bcc1..8404bc8 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -94,22 +94,17 @@ void cmIncludeDirectoryCommand::AddDirectory(const char *i,
}
// remove any leading or trailing spaces and \r
- pos = ret.size()-1;
- while(ret[pos] == ' ' || ret[pos] == '\r')
+ std::string::size_type b = ret.find_first_not_of(" \r");
+ std::string::size_type e = ret.find_last_not_of(" \r");
+ if ((b!=ret.npos) && (e!=ret.npos))
{
- ret.erase(pos);
- pos--;
+ ret.assign(ret, b, 1+e-b); // copy the remaining substring
}
- pos = 0;
- while(ret.size() && ret[pos] == ' ' || ret[pos] == '\r')
+ else
{
- ret.erase(pos,1);
+ return; // if we get here, we had only whitespace in the string
}
- if (!ret.size())
- {
- return;
- }
-
+
if (!cmSystemTools::IsOff(ret.c_str()))
{
cmSystemTools::ConvertToUnixSlashes(ret);