From c2e8cbaa140986b6a27f2c795e2fb9b38e74f094 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Wed, 6 Nov 2024 13:14:18 -0800 Subject: [PATCH] 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. --- llama/runner/image.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llama/runner/image.go b/llama/runner/image.go index 1cb898d3..70058290 100644 --- a/llama/runner/image.go +++ b/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()