Overview
| Artifact ID: | e09d42bf22511ae24bccbfd94d0195d0cf8119b9 |
|---|---|
| Ticket: | adb198c256df8c4192838cc3c1112fb2821314e9
Potential Tcl_Obj leak in tclPathObj.c |
| User & Date: | chw on 2017-07-02 05:03:00 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
I think there are two potential Tcl_Obj leaks in the current version of tclPathObj.c in the TclJoinPath function, as shown in the following patch. The first in a newly introduced code path which releases a Tcl_Obj although it gets used later, the second regarding the path name separator returned as an optional new Tcl_Obj from a VFS implementation which never gets released. Index: generic/tclPathObj.c ================================================================== --- generic/tclPathObj.c +++ generic/tclPathObj.c @@ -916,22 +916,27 @@ * cannot have backslashes either. */ if ((tclPlatform != TCL_PLATFORM_WINDOWS) || (strchr(Tcl_GetString(elt), '\\') == NULL)) { - if (res != NULL) { - TclDecrRefCount(res); - } - if (PATHFLAGS(elt)) { + if (res != NULL) { + TclDecrRefCount(res); + } return TclNewFSPathObj(elt, str, len); } if (TCL_PATH_ABSOLUTE != Tcl_FSGetPathType(elt)) { + if (res != NULL) { + TclDecrRefCount(res); + } return TclNewFSPathObj(elt, str, len); } (void) Tcl_FSGetNormalizedPath(NULL, elt); if (elt == PATHOBJ(elt)->normPathPtr) { + if (res != NULL) { + TclDecrRefCount(res); + } return TclNewFSPathObj(elt, str, len); } } } @@ -1085,10 +1090,11 @@ if (fsPtr->filesystemSeparatorProc != NULL) { Tcl_Obj *sep = fsPtr->filesystemSeparatorProc(res); if (sep != NULL) { separator = TclGetString(sep)[0]; + Tcl_DecrRefCount(sep); } /* Safety check in case the VFS driver caused sharing */ if (Tcl_IsShared(res)) { TclDecrRefCount(res); res = Tcl_DuplicateObj(res); ================================================================== - foundin changed to: "current"
- is_private changed to: "0"
- login: "chw"
- priority changed to: "5 Medium"
- private_contact changed to: "0b3aff16612e1e9f3b675963fa64e01bd1d89307"
- resolution changed to: "None"
- severity changed to: "Critical"
- status changed to: "Open"
- submitter changed to: "chw"
- subsystem changed to: "36. Pathname Management"
- title changed to: "Potential Tcl_Obj leak in tclPathObj.c"
- type changed to: "Bug"