diff options
| author | Gerd Moellmann | 2000-01-01 00:04:52 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-01-01 00:04:52 +0000 |
| commit | 9b784e967651d58d80914c83f254ecd33a10682d (patch) | |
| tree | f02f75f6f09bc6fa244ef4094d134e17cb2e2818 /src | |
| parent | 40891308b8e73488d12d385b49d5901397f2087f (diff) | |
| download | emacs-9b784e967651d58d80914c83f254ecd33a10682d.tar.gz emacs-9b784e967651d58d80914c83f254ecd33a10682d.zip | |
(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 ea19bf734eb..3eaef5446c6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2000-01-01 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * xfns.c (gif_load): Avoid sign extension and thus out of bounds | ||
| 4 | color indices when accessing raster pixels. | ||
| 5 | |||
| 1 | 1999-12-31 Gerd Moellmann <gerd@gnu.org> | 6 | 1999-12-31 Gerd Moellmann <gerd@gnu.org> |
| 2 | 7 | ||
| 3 | * xfns.c: New image functions adapted to Emacs conventions. | 8 | * xfns.c: New image functions adapted to Emacs conventions. |
diff --git a/src/xfns.c b/src/xfns.c index c1c1eaf5c75..a1c30944c32 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -9207,6 +9207,7 @@ gif_load (f, img) | |||
| 9207 | Lisp_Object image; | 9207 | Lisp_Object image; |
| 9208 | int ino, image_left, image_top, image_width, image_height; | 9208 | int ino, image_left, image_top, image_width, image_height; |
| 9209 | gif_memory_source memsrc; | 9209 | gif_memory_source memsrc; |
| 9210 | unsigned char *raster; | ||
| 9210 | 9211 | ||
| 9211 | specified_file = image_spec_value (img->spec, QCfile, NULL); | 9212 | specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 9212 | specified_data = image_spec_value (img->spec, QCdata, NULL); | 9213 | specified_data = image_spec_value (img->spec, QCdata, NULL); |
| @@ -9327,7 +9328,11 @@ gif_load (f, img) | |||
| 9327 | XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f)); | 9328 | XPutPixel (ximg, x, y, FRAME_BACKGROUND_PIXEL (f)); |
| 9328 | } | 9329 | } |
| 9329 | 9330 | ||
| 9330 | /* Read the GIF image into the X image. */ | 9331 | /* Read the GIF image into the X image. We use a local variable |
| 9332 | `raster' here because RasterBits below is a char *, and invites | ||
| 9333 | problems with bytes >= 0x80. */ | ||
| 9334 | raster = (unsigned char *) gif->SavedImages[ino].RasterBits; | ||
| 9335 | |||
| 9331 | if (gif->SavedImages[ino].ImageDesc.Interlace) | 9336 | if (gif->SavedImages[ino].ImageDesc.Interlace) |
| 9332 | { | 9337 | { |
| 9333 | static int interlace_start[] = {0, 4, 2, 1}; | 9338 | static int interlace_start[] = {0, 4, 2, 1}; |
| @@ -9348,8 +9353,7 @@ gif_load (f, img) | |||
| 9348 | 9353 | ||
| 9349 | for (x = 0; x < image_width; x++) | 9354 | for (x = 0; x < image_width; x++) |
| 9350 | { | 9355 | { |
| 9351 | unsigned int i | 9356 | int i = raster[(y * image_width) + x]; |
| 9352 | = gif->SavedImages[ino].RasterBits[(y * image_width) + x]; | ||
| 9353 | XPutPixel (ximg, x + image_left, row + image_top, | 9357 | XPutPixel (ximg, x + image_left, row + image_top, |
| 9354 | pixel_colors[i]); | 9358 | pixel_colors[i]); |
| 9355 | } | 9359 | } |
| @@ -9362,7 +9366,7 @@ gif_load (f, img) | |||
| 9362 | for (y = 0; y < image_height; ++y) | 9366 | for (y = 0; y < image_height; ++y) |
| 9363 | for (x = 0; x < image_width; ++x) | 9367 | for (x = 0; x < image_width; ++x) |
| 9364 | { | 9368 | { |
| 9365 | unsigned i = gif->SavedImages[ino].RasterBits[y * image_width + x]; | 9369 | int i = raster[y * image_width + x]; |
| 9366 | XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); | 9370 | XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); |
| 9367 | } | 9371 | } |
| 9368 | } | 9372 | } |