From 997123666555e12657192e21133d8fa631b22cdf Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Mon, 5 Oct 2020 13:07:52 -0400 Subject: [PATCH] unix: use runtime.KeepAlive in Solaris IoctlSetTermio This ensures that value remains live for the duration of the ioctl system call. This pattern is used in all other IoctlSet* functions but appears to have been forgotten here. Change-Id: I2b26a5c4e7c862f779427b839327b36c1bc78c82 Reviewed-on: https://go-review.googlesource.com/c/sys/+/259637 Trust: Matt Layher Run-TryBot: Matt Layher TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor --- unix/syscall_solaris.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unix/syscall_solaris.go b/unix/syscall_solaris.go index 0e2a696a..fcc0e10f 100644 --- a/unix/syscall_solaris.go +++ b/unix/syscall_solaris.go @@ -13,6 +13,7 @@ package unix import ( + "runtime" "syscall" "unsafe" ) @@ -554,7 +555,9 @@ func Minor(dev uint64) uint32 { //sys ioctl(fd int, req uint, arg uintptr) (err error) func IoctlSetTermio(fd int, req uint, value *Termio) (err error) { - return ioctl(fd, req, uintptr(unsafe.Pointer(value))) + err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) + runtime.KeepAlive(value) + return err } func IoctlGetTermio(fd int, req uint) (*Termio, error) {