From d41502ebb0d9223704d2807407f4cdeb8446f2c9 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 29 May 2020 12:11:04 +0200 Subject: GLSL: Fix freeze on unexpected end of file Fixes: QTCREATORBUG-24070 Change-Id: I2c503932cb2064f4871a4467c26f7af0efb50bc8 Reviewed-by: Eike Ziller --- src/libs/glsl/glsl.g | 2 ++ src/libs/glsl/glslparser.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/libs/glsl/glsl.g b/src/libs/glsl/glsl.g index 314cef0bb7..ee9aab833c 100644 --- a/src/libs/glsl/glsl.g +++ b/src/libs/glsl/glsl.g @@ -576,6 +576,8 @@ AST *Parser::parse(int startToken) if (yytoken != -1) { const QLatin1String s(spell[yytoken]); message = QString::fromLatin1("Unexpected token `%1'").arg(s); + if (yytoken == 0) // do not freeze on unexpected end of file + return nullptr; } for (; _tos; --_tos) { diff --git a/src/libs/glsl/glslparser.cpp b/src/libs/glsl/glslparser.cpp index 17dc26c61f..5b63300682 100644 --- a/src/libs/glsl/glslparser.cpp +++ b/src/libs/glsl/glslparser.cpp @@ -166,6 +166,8 @@ AST *Parser::parse(int startToken) if (yytoken != -1) { const QLatin1String s(spell[yytoken]); message = QString::fromLatin1("Unexpected token `%1'").arg(s); + if (yytoken == 0) // do not freeze on unexpected end of file + return nullptr; } for (; _tos; --_tos) { -- cgit v1.2.3