There is a bug in the BST classifier that it doesn't set the ->next
element in all cases after it allocated a node. I've replaced the code
with the following to make it more resistant to such errors:

void MCastBSTClassifier::upstream_add(int dst, char *link, int node_id)
{
        struct upstream_info **current,
                *newnode;

        for (current = &oif2RP_; *current; current = &(*current)->next) {
                if ((*current)->dst == dst) {
                        free((*current)->oiflink);
                        (*current)->oiflink = strdup(link);
                        (*current)->node_id = node_id;
                        return;
                } // if
        } // for

        newnode = new(struct upstream_info);
        newnode->dst = dst;
        newnode->oiflink = strdup(link);
        newnode->node_id = node_id;
        newnode->next = NULL;

        *current = newnode;
} // MCastBSTClassifier::upstream_add


Cheers,
Baruch

Reply via email to