Skip to content

Commit

Permalink
Fixed crash when string_to_lowercase() is given a null string
Browse files Browse the repository at this point in the history
  • Loading branch information
luciensadi committed Jul 1, 2024
1 parent e24eab2 commit 0117199
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/newdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,9 @@ bool PCIndex::SaveChar(char_data *ch, vnum_t loadroom, bool fromCopyover)
regenerate_subscriber_list_rankings(ch);

// Make sure they're marked as existing in our global cache.
global_existing_player_cache[std::string(string_to_lowercase(GET_CHAR_NAME(ch)))] = TRUE;
if (GET_CHAR_NAME(ch)) {
global_existing_player_cache[std::string(string_to_lowercase(GET_CHAR_NAME(ch)))] = TRUE;
}

return ret;
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,12 @@ char *string_to_uppercase(const char *source) {
char *string_to_lowercase(const char *source) {
static char dest[MAX_STRING_LENGTH];

if (!source) {
mudlog("SYSERR: Received NULL string to string_to_lowercase()!", NULL, LOG_SYSLOG, TRUE);
strlcpy(dest, "", sizeof(dest));
return dest;
}

int i = 0, x = strlen(source);
for (i = 0; i < x; i++){
if (isalpha(source[i])){
Expand Down

0 comments on commit 0117199

Please sign in to comment.