From abcd650b0304b6f11081cb42dcb6d087c602ab65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20J=C5=8Db?= Date: Thu, 9 Dec 2021 20:30:36 -0800 Subject: [PATCH] Fix for crash bug in memcpy If toString is run on an exactly 32 character slice, memcpy will crash. It took me more hours than I care to admit to find and fix this. Hope this can be merged or at least that this PR will serve as a warning to anyone else who may run into this. :) --- src/strings.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strings.sol b/src/strings.sol index b449645a..e45c8944 100644 --- a/src/strings.sol +++ b/src/strings.sol @@ -44,7 +44,7 @@ library strings { function memcpy(uint dest, uint src, uint len) private pure { // Copy word-length chunks while possible - for(; len >= 32; len -= 32) { + for(; len > 32; len -= 32) { assembly { mstore(dest, mload(src)) }