Fixed tst_qfileinfo::group crash if getgrgid fails

QVERIFY2 and gracefully fail with an error message, rather than
crashing, if getgrgid() fails.

Change-Id: I82a7290f83208486577988cc831d5d3cba20f98e
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
Rohan McGovern 2012-02-08 15:03:34 +10:00 committed by Qt by Nokia
parent 3e720809b0
commit 5cd73e5088

View File

@ -1722,7 +1722,13 @@ void tst_QFileInfo::group()
#if defined(Q_OS_UNIX)
struct group *gr;
gid_t gid = getegid();
errno = 0;
gr = getgrgid(gid);
QVERIFY2(gr, qPrintable(
QString("getgrgid returned 0: %1, cannot determine my own group")
.arg(QString::fromLocal8Bit(strerror(errno)))));
expected = QString::fromLocal8Bit(gr->gr_name);
#endif