diff options
author | dgp <dgp@users.sourceforge.net> | 2012-01-26 16:33:17 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2012-01-26 16:33:17 (GMT) |
commit | fb0d06610f8729df71be474692792022459a9ab5 (patch) | |
tree | 5a5647f374f8f81581dbc9253cf690759a5b0ef4 /generic/tclPathObj.c | |
parent | 4e5840745fe8bd929f716debb48a26d381fd8023 (diff) | |
parent | 108e8a50f4cecebcceafb5aa428bc279fc726260 (diff) | |
download | tcl-fb0d06610f8729df71be474692792022459a9ab5.zip tcl-fb0d06610f8729df71be474692792022459a9ab5.tar.gz tcl-fb0d06610f8729df71be474692792022459a9ab5.tar.bz2 |
3475569 Add value-sharing checks before calls that demand unshared arguments.
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r-- | generic/tclPathObj.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index eb19096..c32202d 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -269,6 +269,14 @@ TclFSNormalizeAbsolutePath( } if (!first || (tclPlatform == TCL_PLATFORM_UNIX)) { link = Tcl_FSLink(retVal, NULL, 0); + + /* Safety check in case driver caused sharing */ + if (Tcl_IsShared(retVal)) { + TclDecrRefCount(retVal); + retVal = Tcl_DuplicateObj(retVal); + Tcl_IncrRefCount(retVal); + } + if (link != NULL) { /* * Got a link. Need to check if the link is relative @@ -292,11 +300,6 @@ TclFSNormalizeAbsolutePath( break; } } - if (Tcl_IsShared(retVal)) { - TclDecrRefCount(retVal); - retVal = Tcl_DuplicateObj(retVal); - Tcl_IncrRefCount(retVal); - } /* * We want the trailing slash. @@ -312,7 +315,12 @@ TclFSNormalizeAbsolutePath( */ TclDecrRefCount(retVal); - retVal = link; + if (Tcl_IsShared(link)) { + retVal = Tcl_DuplicateObj(link); + TclDecrRefCount(link); + } else { + retVal = link; + } linkStr = Tcl_GetStringFromObj(retVal, &curLen); /* @@ -1073,6 +1081,12 @@ Tcl_FSJoinPath( if (sep != NULL) { separator = TclGetString(sep)[0]; } + /* Safety check in case the VFS driver caused sharing */ + if (Tcl_IsShared(res)) { + TclDecrRefCount(res); + res = Tcl_DuplicateObj(res); + Tcl_IncrRefCount(res); + } } if (length > 0 && ptr[length -1] != '/') { |