Return false from FileSpec::GetPath early instead of making the return value

dependent on the last byte of the buffer, which could be unitialized.

llvm-svn: 106417
This commit is contained in:
Benjamin Kramer 2010-06-21 14:36:20 +00:00
parent e1ce369628
commit ae39fc196b
1 changed files with 4 additions and 0 deletions

View File

@ -442,6 +442,10 @@ FileSpec::GetPath(char *path, size_t max_path_length) const
{
strncpy (path, filename, max_path_length);
}
else
{
return false;
}
// Any code paths that reach here assume that strncpy, or a similar function was called
// where any remaining bytes will be filled with NULLs and that the string won't be