diff options
author | Jeremy Nicholl <jnicholl@rim.com> | 2012-12-10 19:56:17 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-16 08:55:35 (GMT) |
commit | 6325c61b475e6560d23348a9dcb26e93c2713647 (patch) | |
tree | 1012e431e96522b7d855aefd5b674e981c4589ad | |
parent | cbc4839884daa916136c1354bb0bea3fc9b36bcc (diff) | |
download | Qt-6325c61b475e6560d23348a9dcb26e93c2713647.zip Qt-6325c61b475e6560d23348a9dcb26e93c2713647.tar.gz Qt-6325c61b475e6560d23348a9dcb26e93c2713647.tar.bz2 |
Fix malloc errors from legacy realpath on Mac OSX.
Avoid using realpath(X,0) on Mac OSX at all, since
even on versions of OSX where realpath(X,0) is supported,
we still get the legacy version due to our compiler flags.
If we were to change the -mmacosx-version-min to 10.5 or
higher then this patch would be safe but unnecessary.
Task-number: QTBUG-28282
(cherry picked from commit 67195dc394001ee1c9adc7db97fd6ff9d88e9b0c)
Change-Id: I0e763321aed71b03e6bf256d112cf4b743411626
Signed-off-by: Peter Hartmann <phartmann@rim.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 83113f2..80092ae 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -181,9 +181,16 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, #else char *ret = 0; # if defined(Q_OS_MAC) && !defined(Q_OS_IOS) - // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. + // When using -mmacosx-version-min=10.4, we get the legacy realpath implementation, + // which does not work properly with the realpath(X,0) form. See QTBUG-28282. if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { - ret = realpath(entry.nativeFilePath().constData(), (char*)0); + ret = (char*)malloc(PATH_MAX + 1); + if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { + const int savedErrno = errno; // errno is checked below, and free() might change it + free(ret); + errno = savedErrno; + ret = 0; + } } else { // on 10.5 we can use FSRef to resolve the file path. QString path = QDir::cleanPath(entry.filePath()); |