Ensure vipsload only byte swaps if necessary

Prior to this commit, MSB-ordered vips images were always byte swapped
on both little- and big endian systems. And LSB-ordered vips images
were loaded without a byte swap. This works correctly on little endian
systems, but will not work on big endian systems where the byte swap
must be done vice versa.

This commit ensures that the byte swap only takes place when needed.

See https://github.com/libvips/libvips/issues/1847.
This commit is contained in:
Kleis Auke Wolthuizen 2020-11-23 14:32:36 +01:00
parent 6340e14303
commit 9bb86119e3
1 changed files with 1 additions and 4 deletions

View File

@ -859,10 +859,7 @@ vips_image_build( VipsObject *object )
if( (magic = vips__file_magic( filename )) ) {
/* We may need to byteswap.
*/
guint32 us = vips_amiMSBfirst() ?
VIPS_MAGIC_INTEL : VIPS_MAGIC_SPARC;
if( magic == us ) {
if( GUINT_FROM_BE( magic ) == image->magic ) {
/* Native open.
*/
if( vips_image_open_input( image ) )