Skip to content

Rewriter::InsertTextAfterToken may have overflow issue #129641

@shafik

Description

@shafik

If we look at Rewriter::InsertTextAfterToken, we see that here:

StartOffs += getRangeSize(SourceRange(Loc, Loc), rangeOpts);
getEditBuffer(FID).InsertText(StartOffs, Str, /*InsertAfter*/true);

getRangeSize may return a -1 which could lead to an overflow and would likely not be a good value when passed to InsertText.

This was flagged by static analysis. It looks like a valid issue but I am not sure. It seems like the function is not used anymore so maybe the correct fix is to remove it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categorycode-qualityquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions