interp: extra safety check in string emulation

Этот коммит содержится в:
Ayke van Laethem 2019-01-11 20:19:54 +01:00
родитель 3ebf464da2
коммит c0ab91a263
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -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()