added checks for zero length strings when checking for the last character

This commit is contained in:
Campbell Barton 2008-06-05 13:12:17 +00:00
parent f35289574a
commit 6757b759ea
2 changed files with 7 additions and 5 deletions

@ -1173,10 +1173,12 @@ int BLI_convertstringcode(char *path, const char *basepath)
strcpy(path, tmp);
}
if (path[strlen(path)-1]=='/') {
BLI_cleanup_dir(NULL, path);
} else {
BLI_cleanup_file(NULL, path);
if (path[0]!='\0') {
if ( path[strlen(path)-1]=='/') {
BLI_cleanup_dir(NULL, path);
} else {
BLI_cleanup_file(NULL, path);
}
}
#ifdef WIN32

@ -411,7 +411,7 @@ static PyObject *M_sys_cleanpath( PyObject * self, PyObject * value )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
last = strlen(path)-1;
if ((path[last]=='/') || (path[last]=='\\')) {
if ((last >= 0) && ((path[last]=='/') || (path[last]=='\\'))) {
trailing_slash = 1;
}
BLI_strncpy(cleaned, path, FILE_MAXDIR + FILE_MAXFILE);