Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cxx-string-captured] Report if a string pointer which is the interna…
…l pointer of a cxx string is captured Summary: Before we were reporting when a local variable of type `std::string` was captured, but this was wrong in many cases as the variable was copied before being captured. What we actually wanted to catch is examples like this ``` example { std::string cstring("abc"); const char* ptr = cstring.c_str(); /// access the ptr in a block that goes out of scope. // fine to capture it in a non escaping block /// we expect the cstring to be destroyed here and ptr to point to dangling address.(use after free) } ``` So now we adapted the checker to catch this case instead. We add a new context_info for captured variables for when a variable is the internal pointer of a local variable of a certain type. Then we do a preanalysis to compute this, and in the actual checker we check if the variable is an internal pointer and report accordingly. Reviewed By: skcho Differential Revision: D64836637 fbshipit-source-id: 967eefb645c1d7f3d412a616e64b327e77384fb0
- Loading branch information