Skip to content

Commit 9897df6

Browse files
author
David Case
committed
fix op_bin2num to not corrupt stack
1 parent b931342 commit 9897df6

File tree

2 files changed

+59
-58
lines changed

2 files changed

+59
-58
lines changed

script/interpreter/example_test.go

Lines changed: 55 additions & 57 deletions
Large diffs are not rendered by default.

script/interpreter/operations.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,10 @@ func opcodeBin2num(op *ParsedOpcode, t *thread) error {
10691069
return err
10701070
}
10711071

1072-
b := minimallyEncode(a)
1072+
b := make([]byte, len(a))
1073+
// Copy the bytes so that we don't corrupt the original stack value
1074+
copy(b, a)
1075+
b = minimallyEncode(b)
10731076
if len(b) > t.cfg.MaxScriptNumberLength() {
10741077
return errs.NewError(errs.ErrNumberTooBig, "script numbers are limited to %d bytes", t.cfg.MaxScriptNumberLength())
10751078
}

0 commit comments

Comments
 (0)