View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] bug in XOTcl_DeleteCommandFromToken ?

From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Tue, 30 Nov 2004 23:51:47 +0100

Hi Jeff,

On Tuesday 30 November 2004 20:57, Jeff Hobbs wrote:
> I found this oddity in XOTcl_DeleteCommandFromToken:
>
> XOTclCallStackContent *csc = cs->top;
>
> for (; csc > cs->content; csc--) {
> - if (csc->cmdPtr == cmd)
> - csc->cmdPtr = NULL;
> - break;
> + if (csc->cmdPtr == cmd) {
> + csc->cmdPtr = NULL;
> + break;
> + }
> }
> return Tcl_DeleteCommandFromToken(in, cmd);
> }
>
> Is my fix correct, or is there some magic reason why you
> would want to break after the first 'if' check no matter
> what?

 The code tries to avoid dangling references from the stack
 to cmds. The correct fix is to remove the break.

> BTW - any conditionals without { } is BAD CODE, for exactly
> the above reason.

 agreed.

-gustaf
-- 
Univ.Prof. Dr.Gustaf Neumann
Abteilung für Wirtschaftsinformatik und Neue Medien
Wirtschaftsuniversität Wien, Augasse 2-6, 1090 Wien