Put this big char array on heap for safety reasons

This commit is contained in:
twinaphex 2021-03-30 01:19:50 +02:00
parent ed6dd6d6d1
commit 01944dd80e
1 changed files with 8 additions and 3 deletions

View File

@ -1009,13 +1009,17 @@ static void rcheevos_award_achievement(rcheevos_locals_t *locals,
/* Take a screenshot of the achievement. */
if (settings && settings->bools.cheevos_auto_screenshot)
{
char shotname[8192];
size_t shotname_len = sizeof(char) * 8192;
char *shotname = (char*)malloc(shotname_len);
snprintf(shotname, sizeof(shotname), "%s/%s-cheevo-%u",
if (!shotname)
return;
snprintf(shotname, shotname_len, "%s/%s-cheevo-%u",
settings->paths.directory_screenshot,
path_basename(path_get(RARCH_PATH_BASENAME)),
cheevo->id);
shotname[sizeof(shotname) - 1] = '\0';
shotname[shotname_len - 1] = '\0';
if (take_screenshot(settings->paths.directory_screenshot,
shotname, true,
@ -1028,6 +1032,7 @@ static void rcheevos_award_achievement(rcheevos_locals_t *locals,
CHEEVOS_LOG(
RCHEEVOS_TAG "Failed to capture screenshot for achievement %u\n",
cheevo->id);
free(shotname);
}
}
#endif