epan: Fix build errors about try/catch block on some compilers

The original error was identified in a comment on !8583
This commit is contained in:
Brian Sipos 2022-10-21 19:24:28 -04:00 committed by A Wireshark GitLab Utility
parent 0647fc5f23
commit c4b30942d0
2 changed files with 8 additions and 4 deletions

View File

@ -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);
}

View File

@ -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;
}