From a2c0d38d8ef5767657d4315b568b70bd5be06cfd Mon Sep 17 00:00:00 2001 From: Mo Xiaoming <2188767+mo-xiaoming@users.noreply.github.com> Date: Wed, 6 Jul 2022 23:01:05 +0800 Subject: [PATCH] hobbes::variant tag become invalid causes buffer overrun during destruction calls --- include/hobbes/net.H | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/hobbes/net.H b/include/hobbes/net.H index 6b7a72a9..de791854 100644 --- a/include/hobbes/net.H +++ b/include/hobbes/net.H @@ -807,10 +807,10 @@ template } static bool accum(int s, async_read_state* o, tuple* x) { if (o->template apply, int, tuple*>(s, x)) { - ++o->unsafeTag(); - if (o->unsafeTag() == sizeof...(Fs)) { + if (o->unsafeTag() == sizeof...(Fs)-1) { return true; } else { + ++o->unsafeTag(); variantApp, void*>::apply(o->unsafeTag(), o->unsafePayload(), o->unsafePayload()); return false; } @@ -1013,6 +1013,7 @@ template this->ks.front()(this->r); this->ks.pop(); this->r = R(); + this->pr = async_read_state(); io::prepare(&this->pr); return true; } else {