From 283ef2ae0d724bdd280b3d9dc7a1c700531332bb Mon Sep 17 00:00:00 2001 From: Dulma Churchill Date: Tue, 29 Oct 2024 08:49:29 -0700 Subject: [PATCH] [cxx-string-captured] Improve the documentation 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 --- .../issues/CXX_STRING_CAPTURED_IN_BLOCK.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md b/infer/documentation/issues/CXX_STRING_CAPTURED_IN_BLOCK.md index c09aa235ce2..a846b0fba58 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.