Fix nil pointer dereference in CreateObject

pull/4486/head
fabaoyi 2025-03-13 16:51:00 +08:00
parent 2cba2c4d59
commit faa75104d5
1 changed files with 3 additions and 1 deletions

View File

@ -14,9 +14,11 @@ import (
// CreateObject creates a new object based on the given Xray instance and config. The Xray instance may be nil. // CreateObject creates a new object based on the given Xray instance and config. The Xray instance may be nil.
func CreateObject(v *Instance, config interface{}) (interface{}, error) { func CreateObject(v *Instance, config interface{}) (interface{}, error) {
ctx := v.ctx var ctx context.Context
if v != nil { if v != nil {
ctx = toContext(v.ctx, v) ctx = toContext(v.ctx, v)
} else {
ctx = context.Background()
} }
return common.CreateObject(ctx, config) return common.CreateObject(ctx, config)
} }