mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐛🔥🔒 possible safety concern if interior while auto saving
May corrupt as static, one thread could clear as the other is copying for example
This commit is contained in:
parent
cc17c3f8d3
commit
2d62f51006
1 changed files with 3 additions and 3 deletions
|
|
@ -289,12 +289,12 @@ const char *Bank::Save()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
static std::ofstream users_save(users_location, std::ios::out | std::ios::binary);
|
std::ofstream users_save(users_location, std::ios::out | std::ios::binary);
|
||||||
if (!users_save.is_open())
|
if (!users_save.is_open())
|
||||||
{
|
{
|
||||||
throw std::invalid_argument("Cannot access saving file\n");
|
throw std::invalid_argument("Cannot access saving file\n");
|
||||||
}
|
}
|
||||||
static bank_dom::Global users_copy;
|
bank_dom::Global users_copy;
|
||||||
users_copy.users.clear();
|
users_copy.users.clear();
|
||||||
users_copy.keys.clear();
|
users_copy.keys.clear();
|
||||||
users_copy.users.reserve(users.size());
|
users_copy.users.reserve(users.size());
|
||||||
|
|
@ -310,7 +310,7 @@ const char *Bank::Save()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static FBE::bank_dom::GlobalFinalModel writer;
|
FBE::bank_dom::GlobalFinalModel writer;
|
||||||
writer.serialize(users_copy);
|
writer.serialize(users_copy);
|
||||||
if (!writer.verify())
|
if (!writer.verify())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue