Revert "don't pass null to strlen"

This reverts commit e05efc69ce.
This commit is contained in:
DarthArgus
2018-07-14 15:10:21 +00:00
parent e05efc69ce
commit 5ce8921f80
@@ -47,30 +47,22 @@ FileName::FileName (FileName::Path path, const char* filename, const char* ext)
DEBUG_FATAL (!filename, ("FileName::FileName - filename is 0"));
//-- make sure we have an extention
if (!ext) {
if (!ext)
ext = pathTable [path].ext;
}
size_t prePathLength = 0;
// see if the filename already begins with the path
const char *prePath = pathTable [path].path;
if (prePath != nullptr && *prePath != '\0')
{
prePathLength = strlen(prePath);
if (strncmp(filename, prePath, prePathLength) == 0)
if (strncmp(filename, prePath, strlen(prePath)) == 0)
prePath = "";
}
size_t extLen = 0;
size_t filenameLen = 0;
// see if the filename already ends in the extension
if (ext != nullptr && *ext != '\0')
{
extLen = strlen(ext);
filenameLen = strlen(filename);
int extLen = strlen(ext);
int filenameLen = strlen(filename);
if (filenameLen > extLen + 1)
{
for (--extLen, --filenameLen; extLen >= 0; --extLen, --filenameLen)
@@ -83,8 +75,8 @@ FileName::FileName (FileName::Path path, const char* filename, const char* ext)
}
}
fullName = new char [prePathLength + filenameLen + 1 + extLen + 1];
sprintf(fullName, "%s%s%s%s", prePath, filename, extLen ? "." : "", ext);
fullName = new char [strlen(prePath) + strlen(filename) + 1 + strlen(ext) + 1];
sprintf(fullName, "%s%s%s%s", prePath, filename, strlen(ext) ? "." : "", ext);
}
//-------------------------------------------------------------------