Fix #4750: Nil pointer panic in RegisterExporters (#4769)

This commit is contained in:
Nathan Wallace
2025-11-11 17:58:06 +08:00
committed by GitHub
parent 28fb1d5237
commit da0c9ddc0e
2 changed files with 5 additions and 1 deletions

View File

@@ -46,6 +46,10 @@ func NewInitData() *InitData {
func (i *InitData) RegisterExporters(exporters ...export.Exporter) *InitData {
for _, e := range exporters {
// Skip nil exporters to prevent nil pointer panic
if e == nil {
continue
}
if err := i.ExportManager.Register(e); err != nil {
// short circuit if there is an error
i.Result.Error = err

View File

@@ -110,7 +110,7 @@ func TestInitData_CleanupIdempotency(t *testing.T) {
// TestInitData_NilExporter tests registering nil exporters
func TestInitData_NilExporter(t *testing.T) {
t.Skip("Demonstrates bug #4750 - HIGH nil pointer panic when registering nil exporter. Remove this skip in bug fix PR commit 1, then fix in commit 2.")
// t.Skip("Demonstrates bug #4750 - HIGH nil pointer panic when registering nil exporter. Remove this skip in bug fix PR commit 1, then fix in commit 2.")
initData := NewInitData()
// Register nil exporter - should this panic or handle gracefully?