Skip to content

Commit

Permalink
Fixing bug for strings with size more than 32 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
pouladzade committed Mar 13, 2018
1 parent 15962c4 commit 48384f1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/BytesToTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ contract BytesToTypes {
size := mload(add(_input,_offst))
let chunk_count := add(div(size,32),1) // chunk_count = size/32 + 1

if gt(mod(size,32),0) // if size%32 > 0
{chunk_count := add(chunk_count,1)}
if gt(mod(size,32),0) {// if size%32 > 0
chunk_count := add(chunk_count,1)
}

size := mul(chunk_count,32)// first 32 bytes reseves for size in strings
}
Expand All @@ -47,10 +48,13 @@ contract BytesToTypes {

let chunk_count

mstore(size,mload(add(_input,_offst)))
size := mload(add(_input,_offst))
chunk_count := add(div(size,32),1) // chunk_count = size/32 + 1
jumpi(loop , iszero(mod(size,32))) // if size%32 == 0
chunk_count := add(chunk_count,1) // chunk_count++

if gt(mod(size,32),0) {
chunk_count := add(chunk_count,1) // chunk_count++
}


loop:
mstore(add(_output,mul(loop_index,32)),mload(add(_input,_offst)))
Expand Down

0 comments on commit 48384f1

Please sign in to comment.