🐛 GetLogs Seg fault out range seg

This commit is contained in:
EntireTwix 2021-04-22 00:36:53 -07:00
parent 7e76c668f2
commit 4f657a3ecd
3 changed files with 13 additions and 17 deletions

View file

@ -4,13 +4,6 @@
"address": "0.0.0.0",
"port": 80,
"https": false
},
{
"address": "0.0.0.0",
"port": 443,
"https": true,
"cert": "",
"key": ""
}
]
}

View file

@ -161,18 +161,21 @@ public:
{
Json::Value res = -1;
users.if_contains(name, [&res](const User &u) {
uint32_t j;
for (uint32_t i = u.log.data.size() - 1; i > 0; --i)
if (u.log.data.size())
{
j = u.log.data.size() - 1 - i;
if (!u.log.data[i].amount)
uint32_t j;
for (uint32_t i = u.log.data.size() - 1; i > 0; --i)
{
return;
j = u.log.data.size() - 1 - i;
if (!u.log.data[i].amount)
{
return;
}
res[j]["to"] = u.log.data[i].to;
res[j]["from"] = u.log.data[i].from;
res[j]["amount"] = u.log.data[i].amount;
res[j]["time"] = (Json::UInt64)u.log.data[i].time;
}
res[j]["to"] = u.log.data[i].to;
res[j]["from"] = u.log.data[i].from;
res[j]["amount"] = u.log.data[i].amount;
res[j]["time"] = (Json::UInt64)u.log.data[i].time;
}
});
return res;

View file

@ -44,7 +44,7 @@ int main(int argc, char **argv)
[](const drogon::HttpRequestPtr &req, const drogon::HttpResponsePtr &resp) {
resp->addHeader("Access-Control-Allow-Origin", "*");
});
app().loadConfigFile("../config.json").registerController(API).setThreadNum(std::stoul(argv[3])).enableRunAsDaemon().run();
app().loadConfigFile("../config.json").registerController(API).setThreadNum(std::stoul(argv[3])).run();
return 0;
}