Merge pull request #1226 from nspcc-dev/fix/pusha
vm: make offset in PUSHA relative
This commit is contained in:
commit
2800179ce0
3 changed files with 7 additions and 17 deletions
|
@ -1533,12 +1533,7 @@ func (c *codegen) writeJumps(b []byte) error {
|
|||
if int(index) > len(c.l) {
|
||||
return fmt.Errorf("unexpected label number: %d (max %d)", index, len(c.l))
|
||||
}
|
||||
var offset int
|
||||
if op == opcode.PUSHA {
|
||||
offset = c.l[index]
|
||||
} else {
|
||||
offset = c.l[index] - nextIP + 5
|
||||
}
|
||||
offset := c.l[index] - nextIP + 5
|
||||
if offset > math.MaxInt32 || offset < math.MinInt32 {
|
||||
return fmt.Errorf("label offset is too big at the instruction %d: %d (max %d, min %d)",
|
||||
nextIP-5, offset, math.MaxInt32, math.MinInt32)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue