瀏覽代碼

runner.go: Check for zero length images

If we get a request with a zero length image, it will result in
an out-of-bounds error when we pass the data to the image encoder.
Jesse Gross 5 月之前
父節點
當前提交
c2e8cbaa14
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      llama/runner/image.go

+ 4 - 0
llama/runner/image.go

@@ -68,6 +68,10 @@ func (c *ImageContext) NewEmbed(llamaContext *llama.Context, data []byte, aspect
 		return nil, nil
 	}
 
+	if len(data) <= 0 {
+		return nil, errors.New("received zero length image")
+	}
+
 	hash := c.hashImage(data)
 
 	c.mu.Lock()