From 7db8b17275af1b847b9e299d9a44c2f7b3cbe7d5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 10 Mar 2023 16:58:20 +0200 Subject: [PATCH 16/16] img_save(): Avoid make_dir() failure with empty path See osdn #47550 Signed-off-by: Marko Lindqvist --- common/mapimg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/common/mapimg.c b/common/mapimg.c index f99611568a..ac4df7c88b 100644 --- a/common/mapimg.c +++ b/common/mapimg.c @@ -2050,16 +2050,14 @@ static bool img_save(const struct img *pimg, const char *mapimgfile, return FALSE; } - if (!path_is_absolute(mapimgfile) && path != NULL) { + if (!path_is_absolute(mapimgfile) && path != NULL && path[0] != '\0') { if (!make_dir(path)) { MAPIMG_LOG(_("can't create directory")); return FALSE; } sz_strlcpy(tmpname, path); - if (tmpname[0] != '\0') { - sz_strlcat(tmpname, "/"); - } + sz_strlcat(tmpname, "/"); } else { tmpname[0] = '\0'; } -- 2.39.2