From 424ef0b2b854620ac371f2dce49d57634d602fcb Mon Sep 17 00:00:00 2001 From: Adam Oates <31167933+islonely@users.noreply.github.com> Date: Sun, 13 Mar 2022 07:57:34 +0000 Subject: [PATCH] stbi: fixed panic when trying to load JPG (#13724) --- vlib/stbi/stbi.c.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/stbi/stbi.c.v b/vlib/stbi/stbi.c.v index 835abaecd8..474a3c04cf 100644 --- a/vlib/stbi/stbi.c.v +++ b/vlib/stbi/stbi.c.v @@ -93,7 +93,7 @@ pub fn load(path string) ?Image { data: 0 } // flag := if ext == 'png' { C.STBI_rgb_alpha } else { 0 } - desired_channels := if ext == 'png' { 4 } else { 0 } + desired_channels := if ext in ['png', 'jpg', 'jpeg'] { 4 } else { 0 } res.data = C.stbi_load(&char(path.str), &res.width, &res.height, &res.nr_channels, desired_channels) if desired_channels == 4 && res.nr_channels == 3 {