diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index 272b0cc30d..c1d23295e7 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1027,7 +1027,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( QString rstr = QDir::cleanPath( QDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory()) .absoluteFilePath(args.at(0).toQString(m_tmp1))); - ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0))); + ret << (rstr.isSharedWith(m_tmp1) + ? args.at(0) + : args.count() > 1 && rstr.isSharedWith(m_tmp2) + ? args.at(1) + : ProString(rstr).setSource(args.at(0))); } break; case E_RELATIVE_PATH: diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index f70ee683e2..09482d86d9 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2482,6 +2482,14 @@ void tst_qmakelib::proEval_data() "Project MESSAGE: assign split joined: word: this is a test:done\n" "Project MESSAGE: assign split quoted: word this is a test done" << true; + + // Raw data leak with empty file name. Verify with Valgrind or asan. + QTest::newRow("QTBUG-54550") + << "FULL = /there/is\n" + "VAR = $$absolute_path(, $$FULL/nothing/here/really)" + << "VAR = /there/is/nothing/here/really" + << "" + << true; } static QString formatValue(const ProStringList &vals)