diff --git a/src/fsfw_hal/host/HostFilesystem.cpp b/src/fsfw_hal/host/HostFilesystem.cpp index f8739fb8..026910a6 100644 --- a/src/fsfw_hal/host/HostFilesystem.cpp +++ b/src/fsfw_hal/host/HostFilesystem.cpp @@ -178,6 +178,10 @@ ReturnValue_t HostFilesystem::isDirectory(const char *path, bool &isDirectory) { ReturnValue_t HostFilesystem::getBaseFilename(FilesystemParams params, char *nameBuf, size_t maxLen, size_t &baseNameLen) { std::string path(params.path); + size_t lastPos = path.find_last_of("/\\"); + if (lastPos == std::string::npos) { + return returnvalue::FAILED; + } std::string baseName = path.substr(path.find_last_of("/\\") + 1); if (baseName.size() + 1 > maxLen) { return returnvalue::FAILED;