Skip to content

Commit

Permalink
fix int32 overflow when grabbing strings from wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
guregu committed Jan 11, 2023
1 parent 495a32c commit e9a8c80
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions trealla/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (str *cstring) free(pl *prolog) error {

func (pl *prolog) gets(addr, size int32) (string, error) {
data := pl.memory.Data()
ptr := int(addr)
end := int(addr + size)
ptr := int(uint32(addr))
end := int(uint32(addr + size))
if end >= len(data) {
return "", fmt.Errorf("invalid string of %d length at: %d", size, addr)
}
Expand Down

0 comments on commit e9a8c80

Please sign in to comment.