Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
3fc24013
Commit
3fc24013
authored
Aug 08, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue with overflowing 256 bit integers
parent
d6b0ab30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
vm.go
ethvm/vm.go
+31
-0
No files found.
ethvm/vm.go
View file @
3fc24013
...
...
@@ -245,6 +245,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Add
(
y
,
x
)
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
stack
.
Push
(
base
)
...
...
@@ -255,6 +257,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Sub
(
y
,
x
)
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
stack
.
Push
(
base
)
...
...
@@ -265,6 +269,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Mul
(
y
,
x
)
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
stack
.
Push
(
base
)
...
...
@@ -277,6 +283,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Div
(
y
,
x
)
}
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
stack
.
Push
(
base
)
...
...
@@ -289,6 +297,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Div
(
y
,
x
)
}
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
// Pop result back on the stack
stack
.
Push
(
base
)
...
...
@@ -300,6 +310,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Mod
(
y
,
x
)
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
case
SMOD
:
...
...
@@ -310,6 +322,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Mod
(
y
,
x
)
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
...
...
@@ -321,6 +335,8 @@ func (self *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
base
.
Exp
(
y
,
x
,
Pow256
)
ensure256
(
base
)
self
.
Printf
(
" = %v"
,
base
)
stack
.
Push
(
base
)
...
...
@@ -838,3 +854,18 @@ func (self *Vm) Endl() *Vm {
return
self
}
func
ensure256
(
x
*
big
.
Int
)
{
maxInt
,
_
:=
new
(
big
.
Int
)
.
SetString
(
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
,
0
)
if
x
.
Cmp
(
maxInt
)
>=
0
{
x
.
SetInt64
(
0
)
return
}
// Could have done this with an OR, but big ints are costly.
if
x
.
Cmp
(
new
(
big
.
Int
))
<
0
{
x
.
SetInt64
(
0
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment