Merge pull request #1226 from nspcc-dev/fix/pusha

vm: make offset in PUSHA relative
This commit is contained in:
Roman Khimov 2020-07-23 23:40:21 +03:00 committed by GitHub
commit 2800179ce0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 17 deletions

View file

@ -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)