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