From 9834ac56049408fbd848e364a82aabddc0815a07 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 26 Jun 2019 16:10:11 +0200 Subject: qmlscene: Avoid infinite loop If the root document doesn't contain any executable code, we should terminate with an error message rather than loop forever. Change-Id: Ice2ff10ae5dc9d71df2d1c784597393695ab1d98 Reviewed-by: Simon Hausmann Reviewed-by: Fabian Kosmale --- tools/qmlscene/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/qmlscene') diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index ff31f63ed5..312b180df5 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -271,6 +271,10 @@ static bool checkVersion(const QUrl &url) QTextStream stream(&f); bool codeFound= false; while (!codeFound) { + if (stream.atEnd()) { + fprintf(stderr, "qmlscene: no code found in file '%s'.\n", qPrintable(fileName)); + return false; + } QString line = stream.readLine(); if (line.contains(QLatin1Char('{'))) { codeFound = true; @@ -690,6 +694,8 @@ int main(int argc, char ** argv) // QQuickView if one was created. That case is tracked by // QPointer, so it is safe to delete the component here. delete component; + } else { + exitCode = 1; } } -- cgit v1.2.3