You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cpp/ql/src/Security/CWE/CWE-416/UseOfStringAfterLifetimeEnds.qhelp
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ longer valid. If the pointer is used after the <code>std::string</code> object i
10
10
</p>
11
11
12
12
<p>Typically this problem occurs when a <code>std::string</code> is returned by a function call (or overloaded operator)
13
-
by value, and the result is not immediately stored in a variable by value (or <code>const</code> reference). The resulting
14
-
temporary <code>std::string</code> object is destroyed at the end of the expression statement it is contained in, along
15
-
with any memory returned by a call to <code>c_str</code>.
13
+
by value, and the result is not immediately stored in a variable by value or reference in a way that extends the lifetime of
14
+
the temporary object. The resulting temporary <code>std::string</code> object is destroyed at the end of the expression
15
+
statement it is contained in, along with any memory returned by a call to <code>c_str</code>.
16
16
</p>
17
17
</overview>
18
18
@@ -46,6 +46,7 @@ points to valid memory.
46
46
47
47
<li><ahref="https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM50-CPP.+Do+not+access+freed+memory">MEM50-CPP. Do not access freed memory</a>.</li>
<li>cppreference.com: <ahref="https://en.cppreference.com/w/cpp/language/reference_initialization#Lifetime_of_a_temporary">Lifetime of a temporary</a>.</li>
0 commit comments