QFileSystemEngine: fix realpath() buffer size
realpath() returns at most PATH_MAX _plus_ the terminator. Change-Id: I4c2e3e166a5f476863ad8c6999800e6468535dbe Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
6e8e1da0a8
commit
f3707a5a0c
@ -194,7 +194,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
|
|||||||
# if _POSIX_VERSION >= 200801L
|
# if _POSIX_VERSION >= 200801L
|
||||||
ret = realpath(entry.nativeFilePath().constData(), (char*)0);
|
ret = realpath(entry.nativeFilePath().constData(), (char*)0);
|
||||||
# else
|
# else
|
||||||
ret = (char*)malloc(PATH_MAX);
|
ret = (char*)malloc(PATH_MAX + 1);
|
||||||
if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
|
if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
|
||||||
const int savedErrno = errno; // errno is checked below, and free() might change it
|
const int savedErrno = errno; // errno is checked below, and free() might change it
|
||||||
free(ret);
|
free(ret);
|
||||||
|
Loading…
Reference in New Issue
Block a user