Menu

#319 2 * undefined behaviour ?

2.9
open
None
2
2020-04-05
2014-04-08
dcb
No

1.

Utilities/gdcmjpeg/jccolor.c:99:43: warning: iteration 55823u invokes undefined behavior [-Waggressive-loop-optimizations]

Source code is

rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i;

I suspect you've probably run off the end of the array.

2.

Utilities/gdcmjpeg/jdmerge.c:108:34: warning: iteration 9396u invokes undefined behavior [-Waggressive-loop-optimizations]

Source code is

upsample->Cr_r_tab[i] = (int)
    RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS);

Discussion

  • Mathieu Malaterre

    • assigned_to: Mathieu Malaterre
     
  • Mathieu Malaterre

    • Priority: 5 --> 2
     
  • Mathieu Malaterre

    postponed

     
  • Mathieu Malaterre

    • Group: 2.3 --> 2.5
     
  • Alberto Garcia

    Alberto Garcia - 2020-04-05

    Hi, warning 1 seems legitimate.

    When BITS_IN_JSAMPLE is 16 then MAXJSAMPLE is 65535 and therefore after i > 55822 the result of FIX(0.58700) * i cannot be stored in a 32-bit signed integer.

    It would need to be unsigned at least.

     
  • Alberto Garcia

    Alberto Garcia - 2020-04-05

    This looks like the same as this one (patch included there): https://support.dcmtk.org/redmine/issues/759

     

Log in to post a comment.