summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/SystemTools.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-05-29 12:56:20 (GMT)
committerBrad King <brad.king@kitware.com>2013-05-29 12:56:20 (GMT)
commit2c0c59a2e182e25844ded2a551a79e58ab3b3c49 (patch)
tree55a7a37e8954f9a67c128dd49987067c7ccd0f9f /Source/kwsys/SystemTools.cxx
parent6927b25affcb9e2e01fb226970fd91db143b5101 (diff)
parent927012979e54a69d9d49f188ce73f7b4ca2fb073 (diff)
downloadCMake-2c0c59a2e182e25844ded2a551a79e58ab3b3c49.zip
CMake-2c0c59a2e182e25844ded2a551a79e58ab3b3c49.tar.gz
CMake-2c0c59a2e182e25844ded2a551a79e58ab3b3c49.tar.bz2
Merge branch 'upstream-kwsys' into update-kwsys
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r--Source/kwsys/SystemTools.cxx17
1 files changed, 13 insertions, 4 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 394d65e..158217e 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2742,14 +2742,23 @@ bool SystemTools::FileIsDirectory(const char* name)
}
// Remove any trailing slash from the name except in a root component.
- char buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
+ char local_buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
+ std::string string_buffer;
size_t last = length-1;
if(last > 0 && (name[last] == '/' || name[last] == '\\')
&& strcmp(name, "/") !=0 && name[last-1] != ':')
{
- memcpy(buffer, name, last);
- buffer[last] = 0;
- name = buffer;
+ if(last < sizeof(local_buffer))
+ {
+ memcpy(local_buffer, name, last);
+ local_buffer[last] = 0;
+ name = local_buffer;
+ }
+ else
+ {
+ string_buffer.append(name, last);
+ name = string_buffer.c_str();
+ }
}
// Now check the file node type.