Skip to content

Commit

Permalink
fix potential access violation in gettopchartscore
Browse files Browse the repository at this point in the history
throw out index requests below 0
also fix a compile warn
  • Loading branch information
MinaciousGrace committed Jul 18, 2018
1 parent d8a7575 commit 57dc187
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ class LunaDownloadManager : public Luna<DownloadManager>
string chartkey = SArg(1);
int rank = IArg(2);
int index = rank - 1;
if (!DLMAN->chartLeaderboards.count(chartkey) || index >= static_cast<int>(DLMAN->chartLeaderboards[chartkey].size())) {
if (index < 0 || !DLMAN->chartLeaderboards.count(chartkey) || index >= static_cast<int>(DLMAN->chartLeaderboards[chartkey].size())) {
lua_pushnil(L);
return 1;
}
Expand Down Expand Up @@ -1588,7 +1588,7 @@ class LunaDownloadManager : public Luna<DownloadManager>
{
auto bundle = DLMAN->GetCoreBundle(SArg(1));
lua_createtable(L, bundle.size(), 0);
for (int i = 0; i < bundle.size(); ++i) {
for (size_t i = 0; i < bundle.size(); ++i) {
bundle[i]->PushSelf(L);
lua_rawseti(L, -2, i + 1);
}
Expand Down

0 comments on commit 57dc187

Please sign in to comment.