QFileSystemEngine: fix realpath() buffer size
authorRafael Roquetto <rafael.roquetto.qnx@kdab.com>
Tue, 11 Sep 2012 12:58:32 +0000 (09:58 -0300)
committerQt by Nokia <qt-info@nokia.com>
Tue, 11 Sep 2012 15:40:37 +0000 (17:40 +0200)
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>
src/corelib/io/qfilesystemengine_unix.cpp

index 1bc3c4d..3d75b8c 100644 (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);