Skip to content

Commit 91f860b

Browse files
committed
C++: Add 'cpp/use-of-unique-pointer-after-lifetime-ends' FP.
1 parent 8119a27 commit 91f860b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/UseOfUniquePtrAfterLifetimeEnds/UseOfUniquePointerAfterLifetimeEnds.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
| test.cpp:177:16:177:16 | call to operator* | The underlying unique pointer object is destroyed after the call to 'operator*' returns. |
1010
| test.cpp:177:36:177:36 | call to operator* | The underlying unique pointer object is destroyed after the call to 'operator*' returns. |
1111
| test.cpp:179:11:179:11 | call to operator* | The underlying unique pointer object is destroyed after the call to 'operator*' returns. |
12+
| test.cpp:209:29:209:31 | call to get | The underlying unique pointer object is destroyed after the call to 'get' returns. |

cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/UseOfUniquePtrAfterLifetimeEnds/test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,12 @@ void test2(bool b1, bool b2) {
203203
auto s11 = b2 ? nullptr : sRefRef.get(); // GOOD
204204
const S* s12;
205205
s12 = sRefRef.get(); // GOOD
206+
}
207+
208+
void test_convert_to_bool() {
209+
bool b = get_unique_ptr().get(); // GOOD [FALSE POSITIVE]
210+
211+
if(get_unique_ptr().get()) { // GOOD
212+
213+
}
206214
}

0 commit comments

Comments
 (0)