1 // Evil hack: To simulate memory corruption, we want to fiddle with some internals of std::list.
2 // Make those accessible to us.
4 #define protected public
10 typedef std::list<int> int_list;
14 #ifdef LLDB_USING_LIBCPP
15 int_list *numbers_list = new int_list{1,2,3,4,5,6,7,8,9,10};
17 printf("// Set break point at this line.");
19 #if _LIBCPP_VERSION >= 3800
20 auto *third_elem = numbers_list->__end_.__next_->__next_->__next_;
21 assert(third_elem->__as_node()->__value_ == 3);
22 auto *fifth_elem = third_elem->__next_->__next_;
23 assert(fifth_elem->__as_node()->__value_ == 5);
25 auto *third_elem = numbers_list->__end_.__next_->__next_->__next_;
26 assert(third_elem->__value_ == 3);
27 auto *fifth_elem = third_elem->__next_->__next_;
28 assert(fifth_elem->__value_ == 5);
30 fifth_elem->__next_ = third_elem;
33 // Any attempt to free the list will probably crash the program. Let's just leak it.
34 return 0; // Set second break point at this line.