Use SDL string functions

main
Sam Lantinga 2024-02-12 19:51:48 -08:00
parent 725c79f3ac
commit f2695856d6
1 changed files with 5 additions and 6 deletions

View File

@ -495,15 +495,14 @@ static char *xdg_user_dir_lookup (const char *type)
return NULL;
/* Special case desktop for historical compatibility */
if (SDL_strcmp(type, "DESKTOP") == 0)
{
user_dir = (char*) SDL_malloc(SDL_strlen(home_dir) +
SDL_strlen("/Desktop") + 1);
if (SDL_strcmp(type, "DESKTOP") == 0) {
size_t length = SDL_strlen(home_dir) + SDL_strlen("/Desktop") + 1;
user_dir = (char*) SDL_malloc(length);
if (!user_dir)
return NULL;
strcpy(user_dir, home_dir);
strcat(user_dir, "/Desktop");
SDL_strlcpy(user_dir, home_dir, length);
SDL_strlcat(user_dir, "/Desktop", length);
return user_dir;
}