Skip to content

Commit

Permalink
Do not use unsafe to take address of slice element
Browse files Browse the repository at this point in the history
  • Loading branch information
zikaeroh committed Dec 7, 2019
1 parent c6266f4 commit 1d698ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (al *allocator) LNumber2I(v LNumber) LValue {

// alloc a new float, and store our value into it
al.fptrs = append(al.fptrs, float64(v))
fptr := (*float64)(unsafe.Pointer(al.fheader.Data + uintptr(len(al.fptrs)-1)*unsafe.Sizeof(_fv)))
fptr := &al.fptrs[len(al.fptrs)-1]

// hack our scratch LValue to point to our allocated value
// this scratch lvalue is copied when this function returns meaning the scratch value can be reused
Expand Down

0 comments on commit 1d698ba

Please sign in to comment.