Skip to content

Commit

Permalink
[cxx-string-captured] Improve the documentation
Browse files Browse the repository at this point in the history
Summary: We updated the checker in a previous diff but the documentation was still the old one.

Reviewed By: skcho

Differential Revision: D65140447

fbshipit-source-id: 30f2939b8115ec2a987f53751410c3cd6607f608
  • Loading branch information
dulmarod authored and facebook-github-bot committed Oct 29, 2024
1 parent 7f85732 commit 283ef2a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
This check flags when a local variable of type `std::string` is captured in an escaping block.
This check flags when an internal pointer of a local variable of type `std::string` is captured in an escaping block.
This means that the block will be leaving the current scope, i.e. it is
not annotated with `__attribute__((noescape))`.

Example:

```
- (void)string_captured_in_escaping_block_bad {
std::string fullName;
const char* c = fullName.c_str();
dispatch_async(dispatch_get_main_queue(), ^{
const char* c = fullName.c_str();
...
const char* c1 = c;
});
...;
}
```

This could cause crashes because the variable is likely to be freed if the block
uses it later.
This could cause crashes because the variable is likely to be freed when the code is executed, leaving the pointer dangling.

0 comments on commit 283ef2a

Please sign in to comment.