Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2011-03-08
22:25 • Closed ticket [3202905fff]: Incorrect Tcl Interpreter Obj Result plus 8 othe... artifact: 76d4f21e33 user: dgp
21:54 • Ticket [3202905fff]: 5 changes artifact: 3e0cc7fde7 user: dgp
18:45 • Ticket [3202905fff]: 1 change artifact: 8c6c90ad10 user: msofer
18:43 • Add attachment objresult_example.c to ticket [3202905fffffffff|3202905f... artifact: dc92918cdc user: cjmcdonald
18:43 • Ticket [3202905fff] Incorrect Tcl Interpreter Obj Result status still Open w... artifact: 87380fba44 user: cjmcdonald
11:43 • New ticket [3202905fff]. artifact: 61d36479b3 user: cjmcdonald

Incorrect Tcl Interpreter Obj Result

Closed / Fixed3202905fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2011-03-08 11:43:46
There is a problem with obj results returned from an
interpreter. When the obj result is reset, a tclStringType
internal rep can be left for an empty string.  This then
gives inconsistent results for a new obj result.

The attached example program objresult_example.c
demonstrates the issue.

The problem is in ResetObjResult in tclResult.c, where it is
assumed that the obj result only needs to be reset if it is
not an empty string. Changing this so that is always clears
any internal rep fixes the problem.

This patch is against the 8.5.9 release:

*** tclResult.c.859     Wed Mar 24 15:31:48 2010
--- tclResult.c Tue Mar  8 11:21:20 2011
***************
*** 961,972 ****
        TclNewObj(objResultPtr);
        Tcl_IncrRefCount(objResultPtr);
        iPtr->objResultPtr = objResultPtr;
!     } else if (objResultPtr->bytes != tclEmptyStringRep) {
!       if (objResultPtr->bytes != NULL) {
!           ckfree((char *) objResultPtr->bytes);
        }
-       objResultPtr->bytes = tclEmptyStringRep;
-       objResultPtr->length = 0;
        TclFreeIntRep(objResultPtr);
        objResultPtr->typePtr = NULL;
      }
--- 961,974 ----
        TclNewObj(objResultPtr);
        Tcl_IncrRefCount(objResultPtr);
        iPtr->objResultPtr = objResultPtr;
!     } else {
!       if (objResultPtr->bytes != tclEmptyStringRep) {
!           if (objResultPtr->bytes != NULL) {
!               ckfree((char *) objResultPtr->bytes);
!           }
!           objResultPtr->bytes = tclEmptyStringRep;
!           objResultPtr->length = 0;
        }
        TclFreeIntRep(objResultPtr);
        objResultPtr->typePtr = NULL;
      }
cjmcdonaldplain2011-03-08 18:43:46
File Added - 403697: objresult_example.c
msofer Ticket [3202905fff]: 1 change [History diff]2011-03-08 18:45:52
dgpplain2011-03-08 21:54:01
Bug introduced in checkin a9ae49ef27 2007-11-10

Bad miguel!
dgpplain2011-03-08 22:25:53
allow_comments - 1

fixed in all open branches.
Log in (anonymous is fine) to add a comment.

Attachments: