diff options
author | Vadim Barkov <neverscaired@gmail.com> | 2017-01-29 18:37:53 +0300 |
---|---|---|
committer | Vadim Barkov <neverscaired@gmail.com> | 2017-01-29 18:37:53 +0300 |
commit | 6ddcd33daab9124389fc7db311d1acc1828cc044 (patch) | |
tree | 30a03f05193f290e97a351c6c98b944aa842922f /powerpc | |
parent | adbf1d6d1cb9503fee590eeef8b53f2f51ad0776 (diff) | |
download | libpng-6ddcd33daab9124389fc7db311d1acc1828cc044.tar.gz |
Fixed potential align errors for PowerPC VSX filter functions
The problem is that row and prev_row may not be aligned to the same
byte count. This situation leaded to undefined behaviour.
Diffstat (limited to 'powerpc')
-rw-r--r-- | powerpc/filter_vsx_intrinsics.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/powerpc/filter_vsx_intrinsics.c b/powerpc/filter_vsx_intrinsics.c index 955e19ec9..e92a70899 100644 --- a/powerpc/filter_vsx_intrinsics.c +++ b/powerpc/filter_vsx_intrinsics.c @@ -15,13 +15,21 @@ #ifdef PNG_READ_SUPPORTED -/* This code requires -maltivec and -mabi=altivec on the command line: */ +/* This code requires -maltivec and -mvsx on the command line: */ #if PNG_POWERPC_VSX_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ #include <altivec.h> #if PNG_POWERPC_VSX_OPT > 0 +#ifndef __VSX__ +# error "This code requires VSX support (POWER8 and later). Please provide -mvsx compiler flag." +#endif + +#define vec_ld_unaligned(vec,data) vec = vec_vsx_ld(0,pp) +#define vec_st_unaligned(vec,data) vec_vsx_st(vec,0,data) + + /* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d). * They're positioned like this: * prev: c b @@ -31,7 +39,6 @@ * ( this is taken from ../intel/filter_sse2_intrinsics.c ) */ - void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row, png_const_bytep prev_row) { @@ -58,7 +65,7 @@ void png_read_filter_row_up_vsx(png_row_infop row_info, png_bytep row, while( istop >= 16 ) { rp_vec = vec_ld(0,rp); - pp_vec = vec_ld(0,pp); + vec_ld_unaligned(pp_vec,pp); rp_vec = vec_add(rp_vec,pp_vec); |