Skip to content

Commit 8159098

Browse files
committed
C++: Add test from issue github#5190.
1 parent 49d1937 commit 8159098

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/smart_pointer.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,14 @@ void test_shared_field_member() {
6565
std::unique_ptr<A> p = std::make_unique<A>(source(), 0);
6666
sink(p->x); // $ MISSING: ast,ir
6767
sink(p->y); // not tainted
68+
}
69+
70+
void getNumber(std::shared_ptr<int> ptr) {
71+
*ptr = source();
72+
}
73+
74+
int test_from_issue_5190() {
75+
std::shared_ptr<int> p(new int);
76+
getNumber(p);
77+
sink(*p); // $ MISSING: ast,ir
6878
}

cpp/ql/test/library-tests/dataflow/taint-tests/stl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ namespace std {
348348
class shared_ptr {
349349
public:
350350
shared_ptr() noexcept;
351-
explicit shared_ptr(T*);
351+
explicit shared_ptr(T*); shared_ptr(const shared_ptr&) noexcept;
352352
template<class U> shared_ptr(const shared_ptr<U>&) noexcept;
353353
template<class U> shared_ptr(shared_ptr<U>&&) noexcept;
354354

0 commit comments

Comments
 (0)