aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Lazurkin <dmitry.lazurkin@synesis.ru>2016-11-20 16:39:31 +0300
committerMichael Mann <mmann78@netscape.net>2016-11-22 16:46:48 +0000
commit03a2539b227ee2adc547b6c755cc1d17235a09b9 (patch)
tree651cf6c3658e3795c99a13611bc0f37054df493b
parent0f36cf62b705a25c8b932d9bd2725f4d83248f2e (diff)
extract common logic of proto_item_set_len/proto_item_set_end
Change-Id: I55f9303624471d09b446c10939e5c22bf8e21511 Reviewed-on: https://code.wireshark.org/review/18894 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--epan/proto.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/epan/proto.c b/epan/proto.c
index cfd137d083..978008fa1f 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -5447,17 +5447,9 @@ proto_item_prepend_text(proto_item *pi, const char *format, ...)
}
}
-void
-proto_item_set_len(proto_item *pi, const gint length)
+static void
+finfo_set_len(field_info *fi, const gint length)
{
- field_info *fi;
-
- TRY_TO_FAKE_THIS_REPR_VOID(pi);
-
- fi = PITEM_FINFO(pi);
- if (fi == NULL)
- return;
-
DISSECTOR_ASSERT(length >= 0);
fi->length = length;
@@ -5470,6 +5462,20 @@ proto_item_set_len(proto_item *pi, const gint length)
fi->value.value.bytes->len = length;
}
+void
+proto_item_set_len(proto_item *pi, const gint length)
+{
+ field_info *fi;
+
+ TRY_TO_FAKE_THIS_REPR_VOID(pi);
+
+ fi = PITEM_FINFO(pi);
+ if (fi == NULL)
+ return;
+
+ finfo_set_len(fi, length);
+}
+
/*
* Sets the length of the item based on its start and on the specified
* offset, which is the offset past the end of the item; as the start
@@ -5492,15 +5498,8 @@ proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end)
end += tvb_raw_offset(tvb);
DISSECTOR_ASSERT(end >= fi->start);
length = end - fi->start;
- fi->length = length;
- /*
- * You cannot just make the "len" field of a GByteArray
- * larger, if there's no data to back that length;
- * you can only make it smaller.
- */
- if (fi->value.ftype->ftype == FT_BYTES && length <= (gint)fi->value.value.bytes->len)
- fi->value.value.bytes->len = length;
+ finfo_set_len(fi, length);
}
int