fix: apply Gemini Pro review — maps.Clone for crash metadata

Prevents external mutation of crash handler metadata after construction.
Uses maps.Clone (Go 1.21+) as suggested by Gemini Pro review.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-18 01:02:48 +00:00
parent d1c9d4e4ad
commit 81eba2777a

View file

@ -9,6 +9,7 @@ package core
import (
"encoding/json"
"fmt"
"maps"
"os"
"runtime"
"runtime/debug"
@ -48,7 +49,8 @@ func WithCrashFile(path string) CrashOption {
// WithCrashMeta adds metadata included in every crash report.
func WithCrashMeta(meta map[string]string) CrashOption {
return func(h *CrashHandler) { h.meta = meta }
cloned := maps.Clone(meta)
return func(h *CrashHandler) { h.meta = cloned }
}
// WithCrashHandler sets a callback invoked on every crash.