Skip to content

Instantly share code, notes, and snippets.

@hayeah
Created August 13, 2017 09:05
Show Gist options
  • Save hayeah/73e2c53aab430b3b9f377746ca3e7ce0 to your computer and use it in GitHub Desktop.
Save hayeah/73e2c53aab430b3b9f377746ca3e7ce0 to your computer and use it in GitHub Desktop.
:
0xc0fefe
[0xc0fefe]
0x5
[0x5 0xc0fefe]
dup1
/* array bound checking code */
// 5 < 6
0x6
[0x6 0x5 0xc0fefe]
dup2
[0x5 0x6 0x5 0xc0fefe]
lt
[0x1 0x5 0xc0fefe]
// bound_check_ok = 1 (TRUE)
// if(bound_check_ok) { goto tag5 } else { invalid }
tag_5
[tag_5 0x1 0x5 0xc0fefe]
jumpi
// Test condition is true. Will goto tag_5.
// And `jumpi` consumes two items from stack.
[0x5 0xc0fefe]
invalid
// Array access is valid. Do it.
// stack: [0x5 0xc0fefe]
tag_5:
sstore
[]
storage: { 0x5 => 0xc0fefe }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment