From c4b30942d031d9b8ff7286d5b892ecd6999c285c Mon Sep 17 00:00:00 2001 From: Brian Sipos Date: Fri, 21 Oct 2022 19:24:28 -0400 Subject: [PATCH] epan: Fix build errors about try/catch block on some compilers The original error was identified in a comment on !8583 --- epan/tvbtest.c | 10 +++++++--- epan/tvbuff.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/epan/tvbtest.c b/epan/tvbtest.c index f9f5f445d2..6573092e43 100644 --- a/epan/tvbtest.c +++ b/epan/tvbtest.c @@ -656,15 +656,19 @@ static void varint_tests(void) { tvbuff_t *tvb_parent, *tvb; + volatile unsigned long got_ex; + guint64 got_val; + volatile guint got_len; + tvb_parent = tvb_new_real_data((const guint8*)"", 0, 0); for (size_t ix = 0; ix < (sizeof(varint) / sizeof(varint_test_s)); ++ix) { const varint_test_s *vit = &varint[ix]; tvb = tvb_new_child_real_data(tvb_parent, vit->enc, vit->enc_len, vit->enc_len); - unsigned long got_ex = 0; - guint64 got_val = 0; - guint got_len = 0; + got_ex = 0; + got_val = 0; + got_len = 0; TRY { got_len = tvb_get_varint(tvb, 0, vit->maxlen, &got_val, vit->encoding); } diff --git a/epan/tvbuff.c b/epan/tvbuff.c index be23e3408f..ab1c075fb9 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -4571,7 +4571,7 @@ tvb_get_varint(tvbuff_t *tvb, guint offset, guint maxlen, guint64 *value, const for (i = 0; ((i < FT_VARINT_MAX_LEN) && (i < maxlen)); ++i) { b = tvb_get_guint8(tvb, offset++); - if ((i == 9) && (*value >= (uint64_t)1<<(64-7))) { + if ((i == 9) && (*value >= G_GUINT64_CONSTANT(1)<<(64-7))) { // guaranteed overflow, not valid SDNV return 0; }