Skip to content

Commit

Permalink
Fix negative shift left reported by UBSan (#757)
Browse files Browse the repository at this point in the history
This shall have no performance impact on 2’s complement machine where
the compiler replaces the multiplication by power of two (constant) by
a left shift.
Verified at least on MacOS Xcode 7.3, same assembly generated after fix.
  • Loading branch information
mayeut committed Apr 26, 2016
1 parent c559c62 commit 6f2ac3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/openjp2/t1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ OPJ_BOOL opj_t1_encode_cblks( opj_t1_t *t1,
if (tccp->qmfbid == 1) {
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
tiledp[tileIndex] <<= T1_NMSEDEC_FRACBITS;
tiledp[tileIndex] *= 1 << T1_NMSEDEC_FRACBITS;

This comment has been minimized.

Copy link
@boxerab

boxerab Apr 27, 2016

Contributor

Should there be brackets around the right hand side of the equation? for clarity ?
(1 << T1_NMSEDEC_FRACBITS)

This comment has been minimized.

Copy link
@mayeut

mayeut Apr 27, 2016

Author Collaborator

There's no need for brackets but, since you ask, I'll add them for clarity.

tileIndex++;
}
tileIndex += tileLineAdvance;
Expand Down

1 comment on commit 6f2ac3e

@boxerab
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Please sign in to comment.