summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r--win/tclWinFile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index d3c2e68..6ddb9d0 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -961,6 +961,7 @@ TclpMatchInDirectory(
if (fileNamePtr == NULL) {
return TCL_ERROR;
}
+ Tcl_IncrRefCount(fileNamePtr); /* ensure it'd be alive, while used. */
/*
* Verify that the specified path exists and is actually a directory.
@@ -968,11 +969,13 @@ TclpMatchInDirectory(
native = Tcl_FSGetNativePath(pathPtr);
if (native == NULL) {
+ Tcl_DecrRefCount(fileNamePtr);
return TCL_OK;
}
attr = (*tclWinProcs->getFileAttributesProc)(native);
if ((attr == 0xffffffff) || ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)) {
+ Tcl_DecrRefCount(fileNamePtr);
return TCL_OK;
}
@@ -990,6 +993,7 @@ TclpMatchInDirectory(
Tcl_DStringAppend(&dsOrig, "/", 1);
dirLength++;
}
+ Tcl_DecrRefCount(fileNamePtr);
dirName = Tcl_DStringValue(&dsOrig);
/*