diff options
author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-04 16:04:19 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-08 01:44:26 +0200 |
commit | afb0260f50f41fa72f8447fdb84f8d907a725fe5 (patch) | |
tree | 2d377722655d0086b1c5946542e658b337c9944d | |
parent | 194e0bd7e47a9e7a73597c218ffc3f04a50e8e48 (diff) |
Fix QTest::qExec crash with no command line arguments
The documentation for QTest::qExec states that command line arguments
are optional and gives the following example:
MyTestObject test1;
QTest::qExec(&test1);
However, running this example leads to crash as argv[0] is accessed
without testing argc. This change fixes this bug.
Change-Id: I2ec016e02869d21b24bc11f1851a760036640191
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
-rw-r--r-- | src/testlib/qtestcase.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 3bd6848e13..11d7f68399 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -2114,7 +2114,8 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) QTEST_ASSERT(metaObject); QTestResult::setCurrentTestObject(metaObject->className()); - QTestResult::setCurrentAppname(argv[0]); + if (argc > 0) + QTestResult::setCurrentAppname(argv[0]); qtest_qParseArgs(argc, argv, false); |