diff options
author | Gerd Moellmann <[email protected]> | 2000-01-01 00:04:52 +0000 |
---|---|---|
committer | Gerd Moellmann <[email protected]> | 2000-01-01 00:04:52 +0000 |
commit | 9b784e967651d58d80914c83f254ecd33a10682d (patch) | |
tree | f02f75f6f09bc6fa244ef4094d134e17cb2e2818 /src | |
parent | 40891308b8e73488d12d385b49d5901397f2087f (diff) |
(gif_load): Avoid sign extension and thus out of bounds
color indices when accessing raster pixels.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/xfns.c | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ea19bf734e..3eaef5446c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2000-01-01 Gerd Moellmann <[email protected]> + + * xfns.c (gif_load): Avoid sign extension and thus out of bounds + color indices when accessing raster pixels. + 1999-12-31 Gerd Moellmann <[email protected]> * xfns.c: New image functions adapted to Emacs conventions. diff --git a/src/xfns.c b/src/xfns.c index c1c1eaf5c7..a1c30944c3 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -9207,6 +9207,7 @@ gif_load (f, img) Lisp_Object image; int ino, image_left, image_top, image_width, image_height; gif_memory_source memsrc; + unsigned char *raster; specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); @@ -9327,7 +9328,11 @@ gif_load (f, img) XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f)); } - /* Read the GIF image into the X image. */ + /* Read the GIF image into the X image. We use a local variable + `raster' here because RasterBits below is a char *, and invites + problems with bytes >= 0x80. */ + raster = (unsigned char *) gif->SavedImages[ino].RasterBits; + if (gif->SavedImages[ino].ImageDesc.Interlace) { static int interlace_start[] = {0, 4, 2, 1}; @@ -9348,8 +9353,7 @@ gif_load (f, img) for (x = 0; x < image_width; x++) { - unsigned int i - = gif->SavedImages[ino].RasterBits[(y * image_width) + x]; + int i = raster[(y * image_width) + x]; XPutPixel (ximg, x + image_left, row + image_top, pixel_colors[i]); } @@ -9362,7 +9366,7 @@ gif_load (f, img) for (y = 0; y < image_height; ++y) for (x = 0; x < image_width; ++x) { - unsigned i = gif->SavedImages[ino].RasterBits[y * image_width + x]; + int i = raster[y * image_width + x]; XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); } } |