Ethereal-dev: Re: [Ethereal-dev] proto.c: line 2469: assertion failed

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Guy Harris" <gharris@xxxxxxxxx>
Date: Tue, 21 Sep 2004 16:18:46 -0700 (PDT)
Liu Chunfang-CCL083 said:
> Does anyone know why add this line assert in proto.c?

To catch bugs in protocol dissectors.

> Why my plugin failed on this assertion?

Because there's a bug in it.

To quote the comment before that assertion:

                /*
                 * Make sure we haven't registered this yet.
                 * Most fields have variables associated with them
                 * that are initialized to -1; some have array elements,
                 * or possibly uninitialized variables, so we also allow
                 * 0 (which is unlikely to be the field ID we get back
                 * from "proto_register_field_init()").
                 */

You probably have two entries in the hf_register_info table for your
dissector that both refer to the same variable, e.g.

    static hf_register_info hf[] = {
        { &hf_field,
            { "Field", "xxx.field", ... }
        },

            ...

        { &hf_field,
            { "Field 2", "xxx.field2", ... }
        },

In that example, there should be two separate variables, such as
"hf_field" and "hf_field2".