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:
Rafael Roquetto 2012-09-11 09:58:32 -03:00 committed by Qt by Nokia
parent 6e8e1da0a8
commit f3707a5a0c

View File

@ -194,7 +194,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
# if _POSIX_VERSION >= 200801L
ret = realpath(entry.nativeFilePath().constData(), (char*)0);
# else
ret = (char*)malloc(PATH_MAX);
ret = (char*)malloc(PATH_MAX + 1);
if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
const int savedErrno = errno; // errno is checked below, and free() might change it
free(ret);