From 843b78e2712edab13bbda30662465d443a062716 Mon Sep 17 00:00:00 2001 From: agenthandler <25877731+agenthandler@users.noreply.github.com> Date: Sun, 27 Sep 2026 16:38:05 +0100 Subject: [PATCH] opj_dwt: do not transform a resolution level with no rows opj_dwt_encode_procedure() calls the vertical pass once per group of up to NB_ELTS_V8 columns whenever the resolution level has at least one column, so a level with zero height still reaches opj_dwt_encode_and_deinterleave_v(). At an even start that was harmless, but at an odd start the else branch ran with sn == dn == 0 and addressed tmp[] for two rows that do not exist: OPJ_Sc(0) -= OPJ_Dc(0) and the (height % 2) == 0 tail both touch tmp[NB_ELTS_V8 .. 2*NB_ELTS_V8-1]. The scratch buffer is only opj_dwt_max_resolution() * NB_ELTS_V8 * sizeof(OPJ_INT32) bytes, which is 32 bytes when the tile's largest resolution level is a single sample, so those accesses run past its end. Return early when there is nothing to transform, as opj_dwt_encode_and_deinterleave_v_real() already does for height == 1. One guard covers both the SSE2 and the generic path. This is the vertical counterpart of the horizontal fix in #1657, which this change sits on top of rather than replacing. Also add a self-contained non-regression test for the zero-height case at an odd start, with controls that have no empty resolution level. The horizontal counterpart is left to #1657, so this test passes on master as it stands. --- src/3rdparty/chromium/third_party/pdfium/third_party/libopenjpeg/dwt.c | 4 + diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/libopenjpeg/dwt.c b/src/3rdparty/chromium/third_party/pdfium/third_party/libopenjpeg/dwt.c index 4c2c6a438..c55a626d7 100644 --- a/src/3rdparty/chromium/third_party/pdfium/third_party/libopenjpeg/dwt.c +++ b/src/3rdparty/chromium/third_party/pdfium/third_party/libopenjpeg/dwt.c @@ -1573,6 +1573,10 @@ static void opj_dwt_encode_and_deinterleave_v( const OPJ_UINT32 sn = (height + (even ? 1 : 0)) >> 1; const OPJ_UINT32 dn = height - sn; + if (height == 0) { + return; + } + opj_dwt_fetch_cols_vertical_pass(arrayIn, tmpIn, height, stride_width, cols); #define OPJ_Sc(i) tmp[(i)*2* NB_ELTS_V8 + c]