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

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

View File

@@ -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);