fix: Guard against negative or zero n from ExtraBody to prevent uint underflow

This commit is contained in:
creamlike1024 2025-08-18 23:35:01 +08:00
parent 8a1f6534fc
commit 47ddf76af9

View File

@ -215,7 +215,7 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
if len(request.ExtraBody) > 0 {
var extra map[string]any
if err := json.Unmarshal(request.ExtraBody, &extra); err == nil {
if n, ok := extra["n"].(float64); ok {
if n, ok := extra["n"].(float64); ok && n > 0 {
imgReq.N = uint(n)
}
if size, ok := extra["size"].(string); ok {