qizhrj / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

Bug on opj_write_bytes_BE function #472

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In cio.c source of openjp2. I have found a bug when encode jp2 in Big-endian 
platform

Function:
void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 
p_nb_bytes)

Bug code line:
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes;

Fixed: 
const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + 
sizeof(OPJ_UINT32) - p_nb_bytes;

Original issue reported on code.google.com by vominh2012 on 6 Feb 2015 at 1:47