Merge branch 'fix-FileIsDirectory-SEGV' into release
This commit is contained in:
commit
aad04efe5e
|
@ -2742,14 +2742,23 @@ bool SystemTools::FileIsDirectory(const char* name)
|
|||
}
|
||||
|
||||
// Remove any trailing slash from the name.
|
||||
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)
|
||||
{
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue