From c0ab91a26356b95f28e155b61bdb8bead72ef5d2 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 11 Jan 2019 20:19:54 +0100 Subject: [PATCH] interp: extra safety check in string emulation --- interp/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interp/utils.go b/interp/utils.go index 669afa41..eed46ff3 100644 --- a/interp/utils.go +++ b/interp/utils.go @@ -63,6 +63,9 @@ func getZeroValue(typ llvm.Type) llvm.Value { // getStringBytes loads the byte slice of a Go string represented as a // {ptr, len} pair. func getStringBytes(strPtr Value, strLen llvm.Value) []byte { + if !strLen.IsConstant() { + panic("getStringBytes with a non-constant length") + } buf := make([]byte, strLen.ZExtValue()) for i := range buf { c := strPtr.GetElementPtr([]uint32{uint32(i)}).Load()