changeset 21881:a10888bc9758

Fix invalid read for gifs with a palette for less than 256 colors
author reimar
date Sat, 13 Jan 2007 11:06:40 +0000
parents 4e22e06485c6
children 68ebac1f2b8d
files libmpdemux/demux_gif.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_gif.c	Sat Jan 13 11:05:32 2007 +0000
+++ b/libmpdemux/demux_gif.c	Sat Jan 13 11:06:40 2007 +0000
@@ -119,9 +119,11 @@
 
   {
     int y;
+    int cnt = effective_map->ColorCount;
+    if (cnt > 256) cnt = 256;
 
     // copy the palette
-    for (y = 0; y < 256; y++) {
+    for (y = 0; y < cnt; y++) {
 	priv->palette[(y * 4) + 0] = effective_map->Colors[y].Blue;
 	priv->palette[(y * 4) + 1] = effective_map->Colors[y].Green;
 	priv->palette[(y * 4) + 2] = effective_map->Colors[y].Red;