From c5c0e543e4bb8914ab40b8061bd857cd4f1987ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 13 Jul 2025 20:31:49 +0800 Subject: [PATCH] Logo: don't print builtin logo if the provided logo source cannot be found --- src/logo/logo.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/logo/logo.c b/src/logo/logo.c index c9a7c53b1..72a30e1a6 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -473,21 +473,22 @@ static bool logoPrintData(bool doColorReplacement, FFstrbuf* source) return true; } -static void updateLogoPath(void) +static bool updateLogoPath(void) { FFOptionsLogo* options = &instance.config.logo; if(ffPathExists(options->source.chars, FF_PATHTYPE_FILE)) - return; + return true; if (ffStrbufEqualS(&options->source, "-")) // stdin - return; + return true; FF_STRBUF_AUTO_DESTROY fullPath = ffStrbufCreate(); if (ffPathExpandEnv(options->source.chars, &fullPath) && ffPathExists(fullPath.chars, FF_PATHTYPE_FILE)) { - ffStrbufSet(&options->source, &fullPath); - return; + ffStrbufDestroy(&options->source); + ffStrbufInitMove(&options->source, &fullPath); + return true; } FF_LIST_FOR_EACH(FFstrbuf, dataDir, instance.state.platform.dataDirs) @@ -499,10 +500,13 @@ static void updateLogoPath(void) if(ffPathExists(fullPath.chars, FF_PATHTYPE_FILE)) { - ffStrbufSet(&options->source, &fullPath); - break; + ffStrbufDestroy(&options->source); + ffStrbufInitMove(&options->source, &fullPath); + return true; } } + + return false; } static bool logoPrintFileIfExists(bool doColorReplacement, bool raw) @@ -586,7 +590,13 @@ static bool logoTryKnownType(void) return logoPrintData(false, &source); } - updateLogoPath(); //We sure have a file, resolve relative paths + //We sure have a file, resolve relative paths + if (!updateLogoPath()) + { + if (instance.config.display.showErrors) + fprintf(stderr, "Logo: Failed to resolve logo source: %s\n", options->source.chars); + return false; + } if(options->type == FF_LOGO_TYPE_FILE) return logoPrintFileIfExists(true, false); @@ -649,7 +659,12 @@ void ffLogoPrint(void) return; //Make sure the logo path is set correctly. - updateLogoPath(); + if (!updateLogoPath()) + { + if (instance.config.display.showErrors) + fprintf(stderr, "Logo: Failed to resolve logo source: %s\n", options->source.chars); + return; + } if (ffStrbufEndsWithIgnCaseS(&options->source, ".raw")) {