• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/third_party/libopenjpeg20/j2k.c b/third_party/libopenjpeg20/j2k.c
2index 784a0620a..cea614709 100644
3--- a/third_party/libopenjpeg20/j2k.c
4+++ b/third_party/libopenjpeg20/j2k.c
5@@ -9223,32 +9223,30 @@ static OPJ_BOOL opj_j2k_update_image_dimensions(opj_image_t* p_image,
6
7     l_img_comp = p_image->comps;
8     for (it_comp = 0; it_comp < p_image->numcomps; ++it_comp) {
9-        OPJ_INT32 l_h, l_w;
10-
11         l_img_comp->x0 = opj_uint_ceildiv(p_image->x0, l_img_comp->dx);
12         l_img_comp->y0 = opj_uint_ceildiv(p_image->y0, l_img_comp->dy);
13         l_comp_x1 = opj_int_ceildiv((OPJ_INT32)p_image->x1, (OPJ_INT32)l_img_comp->dx);
14         l_comp_y1 = opj_int_ceildiv((OPJ_INT32)p_image->y1, (OPJ_INT32)l_img_comp->dy);
15
16-        l_w = opj_int_ceildivpow2(l_comp_x1, (OPJ_INT32)l_img_comp->factor)
17-              - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0, (OPJ_INT32)l_img_comp->factor);
18-        if (l_w < 0) {
19+        OPJ_INT32 l_1 = opj_int_ceildivpow2(l_comp_x1, (OPJ_INT32)l_img_comp->factor);
20+        OPJ_INT32 l_2 = opj_int_ceildivpow2((OPJ_INT32)l_img_comp->x0, (OPJ_INT32)l_img_comp->factor);
21+        if (l_1 < l_2) {
22             opj_event_msg(p_manager, EVT_ERROR,
23-                          "Size x of the decoded component image is incorrect (comp[%d].w=%d).\n",
24-                          it_comp, l_w);
25+                          "Size x of the decoded component image is incorrect (comp[%d].w<0).\n",
26+                          it_comp);
27             return OPJ_FALSE;
28         }
29-        l_img_comp->w = (OPJ_UINT32)l_w;
30+        l_img_comp->w = (OPJ_UINT32)(l_1-l_2);
31
32-        l_h = opj_int_ceildivpow2(l_comp_y1, (OPJ_INT32)l_img_comp->factor)
33-              - opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0, (OPJ_INT32)l_img_comp->factor);
34-        if (l_h < 0) {
35+        l_1 = opj_int_ceildivpow2(l_comp_y1, (OPJ_INT32)l_img_comp->factor);
36+        l_2 = opj_int_ceildivpow2((OPJ_INT32)l_img_comp->y0, (OPJ_INT32)l_img_comp->factor);
37+        if (l_1 < l_2) {
38             opj_event_msg(p_manager, EVT_ERROR,
39-                          "Size y of the decoded component image is incorrect (comp[%d].h=%d).\n",
40-                          it_comp, l_h);
41+                          "Size y of the decoded component image is incorrect (comp[%d].h<0).\n",
42+                          it_comp);
43             return OPJ_FALSE;
44         }
45-        l_img_comp->h = (OPJ_UINT32)l_h;
46+        l_img_comp->h = (OPJ_UINT32)(l_1-l_2);
47
48         l_img_comp++;
49     }
50