Minor tweaks

This commit is contained in:
Ray
2018-10-10 23:55:36 +02:00
parent 64778e8cd8
commit 126ab49221
3 changed files with 8 additions and 11 deletions

View File

@@ -1569,8 +1569,9 @@ const char *GetDirectoryPath(const char *fileName)
lastSlash = strprbrk(fileName, "\\/");
if (!lastSlash) return NULL;
// NOTE: Be careful, strncpy() is not safe, it does not care about '\0'
strncpy(filePath, fileName, strlen(fileName) - (strlen(lastSlash) - 1));
filePath[strlen(fileName) - strlen(lastSlash)] = '\0';
filePath[strlen(fileName) - strlen(lastSlash)] = '\0'; // Add '\0' manually
return filePath;
}