mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 13:22:09 +08:00
fix: Nil pointer dereference when context has no engine defined
Issue: #3178
This commit is contained in:
parent
6c3a1d7063
commit
69a5091fd4
@ -1195,7 +1195,7 @@ func (c *Context) Value(key any) any {
|
|||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !c.engine.ContextWithFallback || c.Request == nil || c.Request.Context() == nil {
|
if c == nil || c.engine == nil || !c.engine.ContextWithFallback || c.Request == nil || c.Request.Context() == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return c.Request.Context().Value(key)
|
return c.Request.Context().Value(key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user