Added null pointer handling

This commit is contained in:
Robert Osfield
2016-06-29 17:29:28 +01:00
parent e3c48d9f45
commit 3c1d3b981c

View File

@@ -218,9 +218,14 @@ bool trpgModel::GetType(int &t)
}
bool trpgModel::GetName(char *str,int strLen) const
{
if (!isValid()) return false;
int len = (name ? strlen(name) : 0);
if (!isValid() || !name)
{
return false;
}
int len = strlen(name);
strncpy(str,name,MIN(len,strLen)+1);
return true;
}
bool trpgModel::GetNumTiles(int &ret) const