From ad69dae9e5bbca00aa9a06ad781ec07aa546c28c Mon Sep 17 00:00:00 2001 From: yuntai Date: Wed, 11 Jul 2018 06:23:15 +0900 Subject: [PATCH] Avoid potential 'attempt to add with overflow' panic (#1213) --- core/src/pow/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/pow/mod.rs b/core/src/pow/mod.rs index c1c1ffaec..809d6894d 100644 --- a/core/src/pow/mod.rs +++ b/core/src/pow/mod.rs @@ -98,7 +98,8 @@ pub fn pow_size( } // otherwise increment the nonce - bh.nonce += 1; + let (res, _) = bh.nonce.overflowing_add(1); + bh.nonce = res; // and if we're back where we started, update the time (changes the hash as // well)