From 0ed20efaceab0a003566d51eba0468c03e69cc53 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sun, 16 Nov 2025 13:53:04 +0800 Subject: [PATCH] eth/tracers: fix unsafe pointer manipulation for slice creation, close XFN-91 (#1729) --- eth/tracers/tracer.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index 2fa04cd1ad..8bbd4cc559 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -44,13 +44,9 @@ const bigIntegerJS = `var bigInt=function(undefined){"use strict";var BASE=1e7,L // If those are duktape stack items, popping them off **will** make the slice // contents change. func makeSlice(ptr unsafe.Pointer, size uint) []byte { - var sl = struct { - addr uintptr - len int - cap int - }{uintptr(ptr), int(size), int(size)} - - return *(*[]byte)(unsafe.Pointer(&sl)) + // This is the preferred, officially supported, and safer way + // to create a slice from a raw pointer in modern Go versions. + return unsafe.Slice((*byte)(ptr), int(size)) } // popSlice pops a buffer off the JavaScript stack and returns it as a slice.