diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-10-06 20:46:52 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-10-06 20:46:52 +0000 |
commit | af5b47a0c288d02deb584772501f455b42f1581a (patch) | |
tree | b4e06d0ffcec8e4e517a4e3aa5774fe630c0b105 /epan/proto.c | |
parent | 7183be72b27ed25d381c312dba5c29a81049f629 (diff) |
When registering a field, make sure its ID is -1 or 0 - if it's not,
that probably means you've registered two fields with the same field ID
variable, which is an error.
Fix the bugs doing so found.
svn path=/trunk/; revision=8629
Diffstat (limited to 'epan/proto.c')
-rw-r--r-- | epan/proto.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/epan/proto.c b/epan/proto.c index 6dd9a56110..038a13e365 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.99 2003/08/25 00:15:01 guy Exp $ + * $Id: proto.c,v 1.100 2003/10/06 20:46:52 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -2283,6 +2283,16 @@ proto_register_field_array(int parent, hf_register_info *hf, int num_records) proto = find_protocol_by_id(parent); for (i = 0; i < num_records; i++, ptr++) { + /* + * Make sure we haven't registed 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()"). + */ + g_assert(*ptr->p_id == -1 || *ptr->p_id == 0); + if (proto != NULL) { if (proto->fields == NULL) { proto->fields = g_list_append(NULL, ptr); |