From 00a8e034c8391661dd46325bf50686dd851b40f0 Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Thu, 8 Apr 2021 20:24:46 -0700 Subject: [PATCH] :racehorse: stopping sendfund calls to self --- include/bank.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/bank.hpp b/include/bank.hpp index ca4cf2f..2aa835a 100644 --- a/include/bank.hpp +++ b/include/bank.hpp @@ -60,6 +60,13 @@ public: { //if A exists, A can afford it, and A's password matches bool state = false; + + //cant send money to self, from self + if (a_name == b_name) + { + return false; + } + std::shared_lock lock{save_lock}; //because SendFunds requires 3 locking operations users.modify_if(a_name, [&state, amount, &attempt](User &a) { if (state = (a.balance >= amount) && (a.password == attempt), state)