[vlc-commits] SDL_image: Fix unaligned and potentially out of bound access

Hugo Beauzée-Luyssen git at videolan.org
Tue Apr 7 11:19:06 CEST 2020


vlc/vlc-3.0 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Nov 22 12:28:57 2019 +0100| [72afe7ebd8305bf4f5360293b8621cde52ec506b] | committer: Hugo Beauzée-Luyssen

SDL_image: Fix unaligned and potentially out of bound access

SDL_image allocates an unpadded buffer of height * pitch, causing the
access to the last pixel to be one byte out of bounds

(cherry picked from commit 882147a6b2134de33cabe07923818b95598fb11a)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=72afe7ebd8305bf4f5360293b8621cde52ec506b
---

 modules/codec/sdl_image.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/modules/codec/sdl_image.c b/modules/codec/sdl_image.c
index 65a1223e1a..76290dbd1a 100644
--- a/modules/codec/sdl_image.c
+++ b/modules/codec/sdl_image.c
@@ -224,7 +224,9 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
                 for ( int j = 0; j < p_surface->w; j++ )
                 {
                     uint8_t r, g, b;
-                    SDL_GetRGB( *(uint32_t*)p_src, p_surface->format,
+                    uint32_t pixel = 0;
+                    memcpy(&pixel, p_src, 3);
+                    SDL_GetRGB( pixel, p_surface->format,
                                 &r, &g, &b );
                     *(p_dst++) = r;
                     *(p_dst++) = g;



More information about the vlc-commits mailing list