Skip to content

Commit f3ecc3c

Browse files
committed
Added curl holder double free tests
1 parent d44340b commit f3ecc3c

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ add_cpr_test(threadpool)
7272
add_cpr_test(testUtils)
7373
add_cpr_test(connection_pool)
7474
add_cpr_test(sse)
75+
add_cpr_test(curlholder)
7576

7677
if (ENABLE_SSL_TESTS)
7778
add_cpr_test(ssl)

test/curlholder_tests.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <gtest/gtest.h>
2+
3+
#include <utility>
4+
5+
#include "cpr/curlholder.h"
6+
7+
// Check if there is a double free in curl holder after move.
8+
// To reproduce this, run with address sanitizers enabled.
9+
// https://github.com/libcpr/cpr/issues/1286
10+
TEST(CurlholderTests, MoveOperator) {
11+
cpr::CurlHolder a;
12+
cpr::CurlHolder b;
13+
14+
a = std::move(b);
15+
}
16+
17+
int main(int argc, char** argv) {
18+
::testing::InitGoogleTest(&argc, argv);
19+
return RUN_ALL_TESTS();
20+
}

0 commit comments

Comments
 (0)