Properly handle leaderboard name being NULL (#167)

This commit is contained in:
Mr_Goldberg 2021-08-07 02:11:40 -04:00
parent f041b95c86
commit c5f50ddb32
No known key found for this signature in database
GPG key ID: 8597D87419DEF278

View file

@ -591,6 +591,12 @@ SteamAPICall_t FindOrCreateLeaderboard( const char *pchLeaderboardName, ELeaderb
{ {
PRINT_DEBUG("FindOrCreateLeaderboard %s\n", pchLeaderboardName); PRINT_DEBUG("FindOrCreateLeaderboard %s\n", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchLeaderboardName) {
LeaderboardFindResult_t data;
data.m_hSteamLeaderboard = 0;
data.m_bLeaderboardFound = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
unsigned int leader = find_leaderboard(pchLeaderboardName); unsigned int leader = find_leaderboard(pchLeaderboardName);
if (!leader) { if (!leader) {
@ -616,6 +622,12 @@ SteamAPICall_t FindLeaderboard( const char *pchLeaderboardName )
{ {
PRINT_DEBUG("FindLeaderboard %s\n", pchLeaderboardName); PRINT_DEBUG("FindLeaderboard %s\n", pchLeaderboardName);
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchLeaderboardName) {
LeaderboardFindResult_t data;
data.m_hSteamLeaderboard = 0;
data.m_bLeaderboardFound = 0;
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
}
auto settings_Leaderboards = settings->getLeaderboards(); auto settings_Leaderboards = settings->getLeaderboards();
if (settings_Leaderboards.count(pchLeaderboardName)) { if (settings_Leaderboards.count(pchLeaderboardName)) {