diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index ad34af05ac7..848e45ccb1b 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -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 diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c index b0d18f9f4aa..baae2220143 100644 --- a/source/blender/python/api2_2x/Sys.c +++ b/source/blender/python/api2_2x/Sys.c @@ -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);