Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nit: free memory pointer is not padded after clone() #13

Open
ChiTimesChi opened this issue Apr 18, 2023 · 0 comments
Open

Nit: free memory pointer is not padded after clone() #13

ChiTimesChi opened this issue Apr 18, 2023 · 0 comments

Comments

@ChiTimesChi
Copy link

ChiTimesChi commented Apr 18, 2023

Subtle difference between clone() and join() behavior:

join() pads the updated free memory pointer:

// new pointer is old + 0x20 + the footprint of the body
mstore(0x40, add(add(ptr, _footprint), 0x20))

While clone() does not:

mstore(0x40, add(add(ptr, _len), 0x20)) // write new unused pointer

If a payload having length other than 32 * N bytes is cloned, this will result in the free memory pointer being not padded with a full word size. Which should not impact the library itself, but its consumers might expect the pointer to be always padded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant