Skip to content

Add lifetimebound to ArrayRef and StringRef to detect dangling issues #113533

Closed
@hokein

Description

@hokein

Adding the lifetimebound annotation to the ArrayRef's array constructor can enable us to detect the following use-after-free issues:

ArrayRef<int> test() {
   int array[10];
   return array; // bug, return a stack local address
}

cc @Xazax-hun, @usx95

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:memory-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions