aboutsummaryrefslogtreecommitdiffstats
path: root/community/stb/jpeg-decode-block-overflow.patch
blob: a1278d69f35bd76ef3cb4b2aa8a173231882d9aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From d66d0fe8c1a6ed393817791e4376374fa7f4ecc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20Loba=C4=8Devski?= <jarlob@github.com>
Date: Thu, 19 Oct 2023 15:42:23 +0200
Subject: [PATCH] Fix int overflow

Fixes #1533
---
 stb_image.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stb_image.h b/stb_image.h
index 5e807a0a6..6d63ab32b 100644
--- a/stb_image.h
+++ b/stb_image.h
@@ -2222,7 +2222,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman
    dc = j->img_comp[b].dc_pred + diff;
    j->img_comp[b].dc_pred = dc;
    if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-   data[0] = (short) (dc * dequant[0]);
+   data[0] = (short) ((size_t)dc * dequant[0]);
 
    // decode AC components, see JPEG spec
    k = 1;