From 33ec89306eaaa713b94a32d5126841b07cefbfe9 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Mon, 30 Dec 2024 23:39:36 +0100 Subject: [PATCH] Fix savestate thumbnails - '.png' needs to be appended to the total filepath, so fill_pathname can't be used since it would overwrite the existing extension --- tasks/task_screenshot.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index a291ee547f8..8173eedc488 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -307,8 +307,13 @@ static bool screenshot_dump( if (!fullpath) { if (savestate) - fill_pathname(state->filename, - name_base, ".png", sizeof(state->filename)); + { + size_t _len = strlcpy(state->filename, + name_base, sizeof(state->filename)); + strlcpy(state->filename + _len, + ".png", + sizeof(state->filename) - _len); + } else { char new_screenshot_dir[DIR_MAX_LENGTH]; @@ -361,9 +366,14 @@ static bool screenshot_dump( IMG_EXT, sizeof(state->shotname)); } else - fill_pathname(state->shotname, - path_basename_nocompression(name_base), - ".png", sizeof(state->shotname)); + { + size_t _len = strlcpy(state->shotname, + path_basename_nocompression(name_base), + sizeof(state->shotname)); + strlcpy(state->shotname + _len, + ".png", + sizeof(state->shotname) - _len); + } if ( string_is_empty(new_screenshot_dir) || settings->bools.screenshots_in_content_dir)