From 411d9f0b9c65bfe44d0200a466972ecb9ed5cf00 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 28 Feb 2019 22:29:03 +0200 Subject: [PATCH] Fix protobuf's do not check error value. --- libp2p/protobuf/minprotobuf.nim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libp2p/protobuf/minprotobuf.nim b/libp2p/protobuf/minprotobuf.nim index 14d008d..5cf5b45 100644 --- a/libp2p/protobuf/minprotobuf.nim +++ b/libp2p/protobuf/minprotobuf.nim @@ -203,9 +203,10 @@ proc getVarintValue*(data: var ProtoBuffer, field: int, let res = getSVarint(data.toOpenArray(), length, value) else: let res = PB.getUVarint(data.toOpenArray(), length, value) - data.offset += length - result = length - return + if res == VarintStatus.Success: + data.offset += length + result = length + return # Restore offset on error data.offset = soffset