diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/IteratorToExpiredContainer.expected b/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/IteratorToExpiredContainer.expected index 126f1e8f4f76..d3eed7ecffb5 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/IteratorToExpiredContainer.expected +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/IteratorToExpiredContainer.expected @@ -3,3 +3,4 @@ | test.cpp:702:27:702:27 | call to operator[] | This object is destroyed at the end of the full-expression. | | test.cpp:727:23:727:23 | call to operator[] | This object is destroyed at the end of the full-expression. | | test.cpp:735:23:735:23 | call to operator[] | This object is destroyed at the end of the full-expression. | +| test.cpp:857:3:857:17 | pointer to ~PlusPlusReturnByValueIterator output argument | This object is destroyed at the end of the full-expression. | diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/test.cpp b/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/test.cpp index 84057d80cbe2..d4e3c5b269ae 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/test.cpp +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/IteratorToExpiredContainer/test.cpp @@ -828,3 +828,33 @@ void test6() } } } + +struct PlusPlusReturnByValueIterator +{ + using value_type = int; + using difference_type = std::ptrdiff_t; + using pointer = int *; + using reference = int &; + using iterator_category = std::forward_iterator_tag; + + PlusPlusReturnByValueIterator(); + PlusPlusReturnByValueIterator(PlusPlusReturnByValueIterator const &); + + PlusPlusReturnByValueIterator operator++(); + bool operator==(PlusPlusReturnByValueIterator other) const; + bool operator!=(PlusPlusReturnByValueIterator other) const; + reference operator*() const; + pointer operator->() const; + + ~PlusPlusReturnByValueIterator(); + + PlusPlusReturnByValueIterator begin(); +}; + +void test7() +{ + PlusPlusReturnByValueIterator it; + it.operator++(); // GOOD [FALSE POSITIVE] + + it.begin(); +} \ No newline at end of file