if fd < 0 {
return ""
}
- n := seek(fd, 0, 2)
-
- var p unsafe.Pointer
-
- // Be sure not to allocate for $GOTRACEBACK.
- if key == "GOTRACEBACK" {
- if n >= 128 {
- return ""
- }
- p = unsafe.Pointer(&tracebackbuf[0])
- } else {
- p = gomallocgc(uintptr(n+1), nil, 0)
- }
+ n := seek(fd, 0, 2) - 1
+
+ p := make([]byte, n)
- r := pread(fd, p, int32(n), 0)
+ r := pread(fd, unsafe.Pointer(&p[0]), int32(n), 0)
close(fd)
if r < 0 {
return ""
var s string
sp := (*_string)(unsafe.Pointer(&s))
- sp.str = (*byte)(p)
+ sp.str = &p[0]
sp.len = int(r)
return s
}