From c69768e0e544406a170e92baee7ff00f2493139a Mon Sep 17 00:00:00 2001 From: Cocoa Date: Mon, 18 Mar 2024 03:57:44 +0800 Subject: [PATCH] stb_image: fix: load invalid JPEGs #1608 (#37) --- 3rd_party/stb/stb_image.h | 2 +- test/stb-issue-1608.jpg | Bin 0 -> 177 bytes test/stb_image_test.exs | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/stb-issue-1608.jpg diff --git a/3rd_party/stb/stb_image.h b/3rd_party/stb/stb_image.h index 784be7b..352da9f 100644 --- a/3rd_party/stb/stb_image.h +++ b/3rd_party/stb/stb_image.h @@ -3437,7 +3437,7 @@ static int stbi__decode_jpeg_image(stbi__jpeg *j) if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); m = stbi__get_marker(j); } else { - if (!stbi__process_marker(j, m)) return 1; + if (!stbi__process_marker(j, m)) return stbi__err("bad marker","Corrupt JPEG"); m = stbi__get_marker(j); } } diff --git a/test/stb-issue-1608.jpg b/test/stb-issue-1608.jpg new file mode 100644 index 0000000000000000000000000000000000000000..32ef26592f630dabefbc10fa63b6ce76c5d9fd97 GIT binary patch literal 177 zcmex= + StbImage.read_file!(file) + end + assert_raise ArgumentError, "cannot decode image", fn -> + StbImage.read_binary!(binary) + end + end + end end