Skip to content

In UnsafeBufferUsage.cpp is getEndCharLoc(...) missing an assertion #126334

@shafik

Description

@shafik

Static analysis points out that on this line:

unsigned TkLen = Lexer::MeasureTokenLength(Node->getEndLoc(), SM, LangOpts);

Lexer::MeasureTokenLength can return 0 and on the subsequent line TkLen - 1 will end up as max unsigned which does not look like the code would deal with that gracefully.

This was brought in via 6341301

It looks like the assumption is that this will never return zero, if that is the case there should be an assertion, something like assert(TkLen !=0); to document this invariant.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions