Re: pfSwitch Node

New Message Reply Date view Thread view Subject view Author view

Howard Abrams (abramsh++at++tabor.mitre.org)
Wed, 8 Jun 1994 18:02:38 -0400


Just in case there are people out there who tried this code, there is a
small bug:

> pfSwitch *Group2Switch(pfGroup *grp)
> {
> int i, numPar, numChild;
> pfSwitch *sw;
> sw = pfNewSwitch();
> numPar = pfGetNumParents(grp);
> numChild = pfGetNumChild(grp);
>
> /* add group's children to switch, in same order */
> for (i = 0 ; i < numChild ; i++)
> {
> pfNode *child;
> child = pfGetChild(grp, i);
> pfAddChild(sw, child);
> }
>
> /* remove children from group */
> for (i = 0 ; i < numChild ; i++)
> {
> pfNode *child;
> child = pfGetChild(grp, i);
                                            ^--- this should be 0

If you remove child 0, child 1 becomes child 0. The next time through the
for if you then try to get child 1, and there were only two children,
pfGetChild returns NULL, causing pfRemoveChild to core dump.

Just my $0.02,

  Howard

-- 
Howard Abrams (abramsh++at++mitre.org)                       The MITRE Corporation
Mail Stop W273                              Interactive Simulation Technology
The Mitre Corporation                                 I-Lab Envisioning Group
McLean, VA 22102                                         Phone (703) 883-7421 

These are not Mitre's opinions.... Hell, they're not even mine!


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:19 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.