From 88e8ba9fd86c5b5224a8bf13c63f21e57dff84be Mon Sep 17 00:00:00 2001 From: npt-1707 Date: Thu, 24 Apr 2025 16:37:19 +0800 Subject: [PATCH] Fix potential vulnerable cloned functions\nDecomp: Don't enable 2-pass color quant w/ RGB565 --- modules/juce_graphics/image_formats/jpglib/jdmaster.c | 3 ++- modules/juce_graphics/image_formats/jpglib/jquant2.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/juce_graphics/image_formats/jpglib/jdmaster.c b/modules/juce_graphics/image_formats/jpglib/jdmaster.c index 8c7ec43da12b..c82368f78dd1 100644 --- a/modules/juce_graphics/image_formats/jpglib/jdmaster.c +++ b/modules/juce_graphics/image_formats/jpglib/jdmaster.c @@ -319,7 +319,8 @@ master_selection (j_decompress_ptr cinfo) if (cinfo->raw_data_out) ERREXIT(cinfo, JERR_NOTIMPL); /* 2-pass quantizer only works in 3-component color space. */ - if (cinfo->out_color_components != 3) { + if (cinfo->out_color_components != 3 || + cinfo->out_color_space == JCS_RGB565) { cinfo->enable_1pass_quant = TRUE; cinfo->enable_external_quant = FALSE; cinfo->enable_2pass_quant = FALSE; diff --git a/modules/juce_graphics/image_formats/jpglib/jquant2.c b/modules/juce_graphics/image_formats/jpglib/jquant2.c index 8f50d536ab9f..50d829cc6eae 100644 --- a/modules/juce_graphics/image_formats/jpglib/jquant2.c +++ b/modules/juce_graphics/image_formats/jpglib/jquant2.c @@ -1256,7 +1256,8 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo) cquantize->error_limiter = NULL; /* Make sure jdmaster didn't give me a case I can't handle */ - if (cinfo->out_color_components != 3) + if (cinfo->out_color_components != 3 || + cinfo->out_color_space == JCS_RGB565) ERREXIT(cinfo, JERR_NOTIMPL); /* Allocate the histogram/inverse colormap storage */