diff options
| author | Else <else@localhost> | 2026-04-10 13:27:27 +0200 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-04-10 16:53:03 -0400 |
| commit | 3570cb5fb5e2ae6cfbb65cb4d62ee12c20c1d04b (patch) | |
| tree | bcd05f6832859e63cb7d0a7fa69599061b0b921d | |
| parent | 896b6cd266cd9353d7c3622fd8409a3988cd168a (diff) | |
| download | omnisearch-3570cb5fb5e2ae6cfbb65cb4d62ee12c20c1d04b.tar.gz | |
Handle empty image proxy responses
| -rw-r--r-- | src/Routes/ImageProxy.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Routes/ImageProxy.c b/src/Routes/ImageProxy.c index eb9c7d5..2d6d3a9 100644 --- a/src/Routes/ImageProxy.c +++ b/src/Routes/ImageProxy.c @@ -301,6 +301,13 @@ int image_proxy_handler(UrlParams *params) { int cache_ttl = get_cache_ttl_image(); if (cache_get(cache_key, cache_ttl, &cached_data, &cached_size) == 0) { + if (!cached_data || cached_size == 0) { + free(cached_data); + free(cache_key); + send_response("Empty cached image response"); + return 0; + } + char content_type[64] = {0}; const char *ext = strrchr(url, '.'); @@ -406,6 +413,13 @@ int image_proxy_handler(UrlParams *params) { return 0; } + if (buf.size == 0) { + free(buf.data); + free(cache_key); + send_response("Empty image response"); + return 0; + } + if (strlen(content_type) == 0 || strncmp(content_type, "image/", 6) != 0) { free(buf.data); |
