Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-07-08
03:17 • Closed ticket [949507ffff]: ObjResult feedback loop? plus 3 other changes artifact: 64c76d4c93 user: msofer
2004-05-07
15:27 • Ticket [949507ffff]: 5 changes artifact: a85b82139e user: dkf
04:51 • Ticket [949507ffff]: 4 changes artifact: d43d3173df user: bgriffin
2004-05-06
21:16 • New ticket [949507ffff]. artifact: f47e81c687 user: bgriffin

ObjResult feedback loop?

Closed / Duplicate949507ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 22 years ago
Descriptionplain2004-05-06 21:16:41
I pulled the following code out of tkDND:

  if (Tcl_GetIndexFromObj(infoPtr->interp, 
           Tcl_GetObjResult(infoPtr->interp),
               Actions, "action", 0, &index) == TCL_OK) {

I'm sorry I don't have a reproducable testcase for you,
but, Is it reasonable and legal to pass an ObjResult
object into a function this way or should the ObjResult
object be dupped first?

The problem is that if GetIndex reports an error, it
will write to the interp result object and in this
case, one of the strings appended to the result string
is the result string itself (i.e. the passed in Obj!)

So, is this a bug?  a feature?  abuse of the API?

-Brian
bgriffinplain2004-05-07 04:51:10
Logged In: YES 
user_id=22949

I see this is the same issue as 875395.  Never mind!

-Brian
dkfplain2004-05-07 15:27:56
Logged In: YES 
user_id=79902

The core does all sorts of tricks with assuming blank
objects by default, but it is really not recommended.  From
time to time, I have a quick blitz to remove more instances
of the anti-pattern:
   Tcl_SetIntObj(Tcl_GetObjResult(interp), ....)
etc.

Under normal builds, doing the version with "allocation" is
virtually as efficient and *much* easier to make robust.
msofer Closed ticket [949507ffff]. [History diff]2004-07-08 03:17:43
Log in (anonymous is fine) to add a comment.