2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-18 13:59:46 +00:00

Fix reading from freed memory in rpl::take().

This commit is contained in:
John Preston
2017-10-13 19:33:38 +03:00
parent 583b0fa778
commit 6445c0563e
5 changed files with 30 additions and 8 deletions

View File

@@ -406,6 +406,24 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
*sum += "done";
}, lifetime);
}
REQUIRE(*sum == "012done");
{
rpl::lifetime lifetime;
rpl::ints(3) | take(3)
| start_with_next_done([=](int value) {
*sum += std::to_string(value);
}, [=] {
*sum += "done";
}, lifetime);
}
{
rpl::lifetime lifetime;
rpl::ints(3) | take(10)
| start_with_next_done([=](int value) {
*sum += std::to_string(value);
}, [=] {
*sum += "done";
}, lifetime);
}
REQUIRE(*sum == "012done012done012done");
}
}