diff options
| author | sebres <sebres@users.sourceforge.net> | 2025-07-18 17:29:45 (GMT) |
|---|---|---|
| committer | sebres <sebres@users.sourceforge.net> | 2025-07-18 17:29:45 (GMT) |
| commit | 9ff2ef9fe1182691137f06690891b27b24890dd3 (patch) | |
| tree | 9ec68fd89f809f76f032a03b41fbedfc1bfe1736 /win/tclWinFile.c | |
| parent | 635ba5bd1494ba8eadc4432c5a4d789c3a8ca9c6 (diff) | |
| parent | 6f2c08cfba0904f3bbd9f983e04381b4e86fccee (diff) | |
| download | tcl-9ff2ef9fe1182691137f06690891b27b24890dd3.zip tcl-9ff2ef9fe1182691137f06690891b27b24890dd3.tar.gz tcl-9ff2ef9fe1182691137f06690891b27b24890dd3.tar.bz2 | |
merge 8.5 to 8.6: fixes [61c01e0edb08a9ed] (TclpMatchInDirectory, windows only), increment ref-count to avoid use-after-free for interim normalized path object, what may cause crash (SF/BO), usage of wrong path, etc.
Diffstat (limited to 'win/tclWinFile.c')
| -rw-r--r-- | win/tclWinFile.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index b8e2e30..9087361 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -981,6 +981,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. @@ -988,12 +989,14 @@ TclpMatchInDirectory( native = (const WCHAR *)Tcl_FSGetNativePath(pathPtr); if (native == NULL) { + Tcl_DecrRefCount(fileNamePtr); return TCL_OK; } attr = GetFileAttributesW(native); if ((attr == INVALID_FILE_ATTRIBUTES) || ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)) { + Tcl_DecrRefCount(fileNamePtr); return TCL_OK; } @@ -1011,6 +1014,7 @@ TclpMatchInDirectory( TclDStringAppendLiteral(&dsOrig, "/"); dirLength++; } + Tcl_DecrRefCount(fileNamePtr); dirName = Tcl_DStringValue(&dsOrig); /* |
