forked from qt-creator/qt-creator
CppEditor: Add assertions to CppRefactoringFile::{start,end}Of(AST *)
I've seen this crash once with a null pointer. Change-Id: I162e36155f030712f697da0bbf39ea5fef849db3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -191,6 +191,7 @@ int CppRefactoringFile::startOf(unsigned index) const
|
||||
|
||||
int CppRefactoringFile::startOf(const AST *ast) const
|
||||
{
|
||||
QTC_ASSERT(ast, return 0);
|
||||
int firstToken = ast->firstToken();
|
||||
const int lastToken = ast->lastToken();
|
||||
while (tokenAt(firstToken).generated() && firstToken < lastToken)
|
||||
@@ -207,6 +208,7 @@ int CppRefactoringFile::endOf(unsigned index) const
|
||||
|
||||
int CppRefactoringFile::endOf(const AST *ast) const
|
||||
{
|
||||
QTC_ASSERT(ast, return 0);
|
||||
int lastToken = ast->lastToken() - 1;
|
||||
QTC_ASSERT(lastToken >= 0, return -1);
|
||||
const int firstToken = ast->firstToken();
|
||||
|
Reference in New Issue
Block a user