Skip to content

Commit 30ccea6

Browse files
Copilotpikann
andauthored
fix: copy Fetch response before allocator reset
Agent-Logs-Url: https://github.com/Paca-AI/plugin-sdk-go/sessions/34f8083a-e90b-40b6-8efc-1cd710463eb5 Co-authored-by: pikann <41873019+pikann@users.noreply.github.com>
1 parent 228d0a5 commit 30ccea6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

wasm_backends.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ func Fetch(method, rawURL string, headers map[string]string, body string) (*Fetc
242242
)
243243
resPtr := int32(uint32(outputBuf[0]) | uint32(outputBuf[1])<<8 | uint32(outputBuf[2])<<16 | uint32(outputBuf[3])<<24)
244244
resLen := int32(uint32(outputBuf[4]) | uint32(outputBuf[5])<<8 | uint32(outputBuf[6])<<16 | uint32(outputBuf[7])<<24)
245-
defer wasmResetAllocator()
246245
if resLen == 0 {
247246
return nil, fmt.Errorf("plugin: fetch: empty response from host")
248247
}
249-
resBytes := wasmSlice(resPtr, resLen)
248+
resBytes := append([]byte(nil), wasmSlice(resPtr, resLen)...)
249+
wasmResetAllocator()
250250
var resp FetchResponse
251251
if err := json.Unmarshal(resBytes, &resp); err != nil {
252252
return nil, fmt.Errorf("plugin: fetch: decode response: %w", err)

0 commit comments

Comments
 (0)