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 Change-Id: Iee21003f3e9616482483a05ceee706b476091914 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>bb10
parent
90cb4d8e2e
commit
67195dc394
|
|
@ -174,9 +174,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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue