diff --git a/infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md b/infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md index c09aa235ce..a846b0fba5 100644 --- a/infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md +++ b/infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md @@ -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.