Index: xvfs-core.c ================================================================== --- xvfs-core.c +++ xvfs-core.c @@ -25,18 +25,26 @@ /* * Internal Core Utilities */ static const char *xvfs_relativePath(Tcl_Obj *path, struct xvfs_tclfs_instance_info *info) { + Tcl_Obj *currentDirectory; const char *pathStr, *rootStr; const char *pathFinal; int pathLen, rootLen; rootStr = Tcl_GetStringFromObj(info->mountpoint, &rootLen); pathStr = Tcl_GetStringFromObj(path, &pathLen); if (pathStr[0] != '/') { - path = Tcl_ObjPrintf("%s/%s", Tcl_GetString(Tcl_FSGetCwd(NULL)), pathStr); + currentDirectory = Tcl_FSGetCwd(NULL); + Tcl_IncrRefCount(currentDirectory); + + /* XXX:TODO: Free this */ + path = Tcl_ObjPrintf("%s/%s", Tcl_GetString(currentDirectory), pathStr); + Tcl_IncrRefCount(path); + Tcl_DecrRefCount(currentDirectory); + pathStr = Tcl_GetStringFromObj(path, &pathLen); } if (pathLen < rootLen) { return(NULL); @@ -539,12 +547,12 @@ if (!Tcl_StringMatch(child, pattern)) { continue; } childObj = Tcl_DuplicateObj(path); - Tcl_AppendStringsToObj(childObj, "/", child, NULL); Tcl_IncrRefCount(childObj); + Tcl_AppendStringsToObj(childObj, "/", child, NULL); if (!xvfs_tclfs_verifyType(childObj, types, instanceInfo)) { Tcl_DecrRefCount(childObj); continue; @@ -660,14 +668,18 @@ xvfs_tclfs_standalone_fs.getCwdProc = NULL; xvfs_tclfs_standalone_fs.chdirProc = NULL; xvfs_tclfs_standalone_info.fsInfo = fsInfo; xvfs_tclfs_standalone_info.mountpoint = Tcl_NewObj(); + + Tcl_IncrRefCount(xvfs_tclfs_standalone_info.mountpoint); Tcl_AppendStringsToObj(xvfs_tclfs_standalone_info.mountpoint, XVFS_ROOT_MOUNTPOINT, fsInfo->name, NULL); - + tcl_ret = Tcl_FSRegister(NULL, &xvfs_tclfs_standalone_fs); if (tcl_ret != TCL_OK) { + Tcl_DecrRefCount(xvfs_tclfs_standalone_info.mountpoint); + if (interp) { Tcl_SetResult(interp, "Tcl_FSRegister() failed", NULL); } return(tcl_ret);