Skip to content
Permalink
Browse files

Fix: Possible double path separator in FiosMakeFilename

  • Loading branch information
j-pet committed Aug 17, 2019
1 parent f0aea2d commit 66ce92ec259af253bdd4c6ada5aa5ba1ccf0cafd
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/fios.cpp
@@ -205,12 +205,16 @@ const char *FiosBrowseTo(const FiosItem *item)
*/
static void FiosMakeFilename(char *buf, const char *path, const char *name, const char *ext, const char *last)
{
const char *period;
const char *buf_start = buf;
buf = strecpy(buf, path, last);
/* Remove trailing path separator, if present */
if (buf > buf_start && !IsUtf8Part(buf[-1]) && buf[-1] == PATHSEPCHAR) buf--;

/* Don't append the extension if it is already there */
period = strrchr(name, '.');
const char *period = strrchr(name, '.');
if (period != nullptr && strcasecmp(period, ext) == 0) ext = "";
seprintf(buf, last, "%s" PATHSEP "%s%s", path, name, ext);

seprintf(buf, last, PATHSEP "%s%s", name, ext);
}

/**

0 comments on commit 66ce92e

Please sign in to comment.
You can’t perform that action at this time.