aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/common.go')
-rw-r--r--core/vm/common.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/core/vm/common.go b/core/vm/common.go
index 779cee006..17de38dec 100644
--- a/core/vm/common.go
+++ b/core/vm/common.go
@@ -34,7 +34,21 @@ func calcMemSize(off, l *big.Int) *big.Int {
// getData returns a slice from the data based on the start and size and pads
// up to size with zero's. This function is overflow safe.
-func getData(data []byte, start, size *big.Int) []byte {
+func getData(data []byte, start uint64, size uint64) []byte {
+ length := uint64(len(data))
+ if start > length {
+ start = length
+ }
+ end := start + size
+ if end > length {
+ end = length
+ }
+ return common.RightPadBytes(data[start:end], int(size))
+}
+
+// getDataBig returns a slice from the data based on the start and size and pads
+// up to size with zero's. This function is overflow safe.
+func getDataBig(data []byte, start *big.Int, size *big.Int) []byte {
dlen := big.NewInt(int64(len(data)))
s := math.BigMin(start, dlen)