diff options
| author | Matthieu Darbois <mayeut@users.noreply.github.com> | 2016-04-27 21:56:09 +0200 |
|---|---|---|
| committer | Matthieu Darbois <mayeut@users.noreply.github.com> | 2016-04-27 21:56:09 +0200 |
| commit | e6881e75279627096fbbaca19e837252737a3892 (patch) | |
| tree | c05a6c766db204f7ce2f9db5cd499d6296c3763d /src/lib | |
| parent | 2296dc9e68e0ebc8342a8669aa2398a029b0fa3f (diff) | |
Fix negative shift left reported by UBSan (#758)
Follow-up of #757
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.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/openjp2/t1.c | 2 | ||||
| -rw-r--r-- | src/lib/openjp2/tcd.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/openjp2/t1.c b/src/lib/openjp2/t1.c index 8d020bb5..a3ca93e8 100644 --- a/src/lib/openjp2/t1.c +++ b/src/lib/openjp2/t1.c @@ -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] *= 1 << T1_NMSEDEC_FRACBITS; + tiledp[tileIndex] *= (1 << T1_NMSEDEC_FRACBITS); tileIndex++; } tileIndex += tileLineAdvance; diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 6eeb211e..af6b53f5 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -1911,7 +1911,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_encode ( opj_tcd_t *p_tcd ) } else { for (i = 0; i < l_nb_elem; ++i) { - *l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) << 11 ; + *l_current_ptr = (*l_current_ptr - l_tccp->m_dc_level_shift) * (1 << 11); ++l_current_ptr; } } |
