Run clang-format
This commit is contained in:
@@ -1,44 +1,46 @@
|
||||
#include <mutex>
|
||||
|
||||
class some_data
|
||||
{
|
||||
int a;
|
||||
std::string b;
|
||||
class some_data {
|
||||
int a;
|
||||
std::string b;
|
||||
|
||||
public:
|
||||
void do_something()
|
||||
{}
|
||||
void do_something() {}
|
||||
};
|
||||
|
||||
class data_wrapper
|
||||
{
|
||||
class data_wrapper {
|
||||
private:
|
||||
some_data data;
|
||||
std::mutex m;
|
||||
some_data data;
|
||||
std::mutex m;
|
||||
|
||||
public:
|
||||
template<typename Function>
|
||||
void process_data(Function func)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m);
|
||||
func(data);
|
||||
}
|
||||
template <typename Function>
|
||||
void process_data(Function func)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m);
|
||||
func(data);
|
||||
}
|
||||
};
|
||||
|
||||
some_data* unprotected;
|
||||
|
||||
void malicious_function(some_data& protected_data)
|
||||
void
|
||||
malicious_function(some_data& protected_data)
|
||||
{
|
||||
unprotected=&protected_data;
|
||||
unprotected = &protected_data;
|
||||
}
|
||||
|
||||
data_wrapper x;
|
||||
|
||||
void foo()
|
||||
void
|
||||
foo()
|
||||
{
|
||||
x.process_data(malicious_function);
|
||||
unprotected->do_something();
|
||||
x.process_data(malicious_function);
|
||||
unprotected->do_something();
|
||||
}
|
||||
|
||||
int main()
|
||||
int
|
||||
main()
|
||||
{
|
||||
foo();
|
||||
foo();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user