Tcl Source Code

Artifact [6c98e18c46]
Login

Artifact 6c98e18c468bbf481ccc9b91f6101306367d0232:

Attachment "tclPathObj.c.patch" to ticket [3475569fff] added by sebres 2012-01-19 01:30:48.
Index: tclPathObj.c
===================================================================
--- tclPathObj.c	(revision 84)
+++ tclPathObj.c	(working copy)
@@ -257,6 +257,7 @@
 		 * Have '..' so need to skip previous directory.
 		 */
 
+		// [SB] here will be created brand new retVal object (+ refCount = 1)
 		if (retVal == NULL) {
 		    const char *path = TclGetString(pathPtr);
 
@@ -268,7 +269,10 @@
 		    Tcl_AppendToObj(retVal, dirSep, 1);
 		}
 		if (!first || (tclPlatform == TCL_PLATFORM_UNIX)) {
+		    // [SB] hereafter in "normally" mode refCount = 1, in "DeletePending" mode refCount = 2 :
 		    link = Tcl_FSLink(retVal, NULL, 0);
+		    // [SB] retVal->refCount: "normally" mode refCount = 1, in "DeletePending" mode refCount = 2
+		    // [SB] link is a NULL
 		    if (link != NULL) {
 			/*
 			 * Got a link. Need to check if the link is relative
@@ -292,6 +296,9 @@
 				    break;
 				}
 			    }
+			    // [SB] this workaround is for this part only, but 
+			    // unexpected incr. for obj refCount could be found anywhere,
+			    // since DeletePending introduced.
 			    if (Tcl_IsShared(retVal)) {
 				TclDecrRefCount(retVal);
 				retVal = Tcl_DuplicateObj(retVal);
@@ -340,9 +347,12 @@
 
 		    while (--curLen >= 0) {
 			if (IsSeparatorOrNull(linkStr[curLen])) {
+			    // [SB] here we have BOOM, refCount of retVal is unexpected "2" ...
 			    if (curLen) {
+				// [SB] here ...
 				Tcl_SetObjLength(retVal, curLen);
 			    } else {
+				// [SB] or here ...
 				Tcl_SetObjLength(retVal, 1);
 			    }
 			    break;