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/openjp2/tcd.c | |
| 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/openjp2/tcd.c')
| -rw-r--r-- | src/lib/openjp2/tcd.c | 2 |
1 files changed, 1 insertions, 1 deletions
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; } } |
