proto: ensure valid width through assert.

Found by scan-build.

Change-Id: I467e56bfa4f20f5c87efa47823d54691503de318
Reviewed-on: https://code.wireshark.org/review/31486
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Dario Lombardo 2019-01-11 12:24:46 +01:00 committed by Anders Broman
parent e984cdeb22
commit 82326d21fd
1 changed files with 4 additions and 1 deletions

View File

@ -4609,7 +4609,6 @@ proto_tree_set_boolean(field_info *fi, guint64 value)
/* Generate, into "buf", a string showing the bits of a bitfield.
Return a pointer to the character after that string. */
/*XXX this needs a buf_len check */
static char *
other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, const int width)
{
@ -4619,6 +4618,10 @@ other_decode_bitfield_value(char *buf, const guint64 val, const guint64 mask, co
i = 0;
p = buf;
/* This is a devel error. It is safer to stop here. */
DISSECTOR_ASSERT(width >= 1);
bit = G_GUINT64_CONSTANT(1) << (width - 1);
for (;;) {
if (mask & bit) {