Added missing varint size check

This commit is contained in:
Martin Tůma 2025-01-06 09:44:53 +01:00
parent cbc0a05341
commit b630d1d205

View File

@ -18,8 +18,9 @@ static bool varint(CTX &ctx, T &val)
{ {
val = 0; val = 0;
uint shift = 0; uint shift = 0;
const char *end = qMin(ctx.be, ctx.bp + sizeof(val));
while (ctx.bp < ctx.be) { while (ctx.bp < end) {
val |= ((quint8)*ctx.bp & 0x7F) << shift; val |= ((quint8)*ctx.bp & 0x7F) << shift;
shift += 7; shift += 7;
if (!((quint8)*ctx.bp++ & 0x80)) if (!((quint8)*ctx.bp++ & 0x80))