Files
steampipe/pkg/pluginmanager/state_test.go
Nathan Wallace 9d8f135805 Nil pointer dereference in State.reattachConfig() closes #4755 (#4893)
* Add test for #4755: Nil pointer dereference in State.reattachConfig()

* Fix #4755: Add nil check in State.reattachConfig()
2025-11-16 15:51:19 -05:00

28 lines
702 B
Go

package pluginmanager
import (
"testing"
"github.com/hashicorp/go-plugin"
)
// TestStateWithNilAddr tests that reattachConfig handles nil Addr gracefully
// This test demonstrates bug #4755
func TestStateWithNilAddr(t *testing.T) {
state := &State{
Protocol: plugin.ProtocolGRPC,
ProtocolVersion: 1,
Pid: 12345,
Executable: "/usr/local/bin/steampipe",
Addr: nil, // Nil address - this will cause panic without fix
}
// This should not panic - it should return nil gracefully
config := state.reattachConfig()
// With nil Addr, we expect nil config (not a panic)
if config != nil {
t.Error("Expected nil reattach config when Addr is nil")
}
}