mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 23:43:40 +00:00
interp: extra safety check in string emulation
This commit is contained in:
@@ -63,6 +63,9 @@ func getZeroValue(typ llvm.Type) llvm.Value {
|
|||||||
// getStringBytes loads the byte slice of a Go string represented as a
|
// getStringBytes loads the byte slice of a Go string represented as a
|
||||||
// {ptr, len} pair.
|
// {ptr, len} pair.
|
||||||
func getStringBytes(strPtr Value, strLen llvm.Value) []byte {
|
func getStringBytes(strPtr Value, strLen llvm.Value) []byte {
|
||||||
|
if !strLen.IsConstant() {
|
||||||
|
panic("getStringBytes with a non-constant length")
|
||||||
|
}
|
||||||
buf := make([]byte, strLen.ZExtValue())
|
buf := make([]byte, strLen.ZExtValue())
|
||||||
for i := range buf {
|
for i := range buf {
|
||||||
c := strPtr.GetElementPtr([]uint32{uint32(i)}).Load()
|
c := strPtr.GetElementPtr([]uint32{uint32(i)}).Load()
|
||||||
|
|||||||
Reference in New Issue
Block a user