diff options
| author | Lars Ingebrigtsen | 2022-04-12 15:11:09 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2022-04-12 15:11:32 +0200 |
| commit | 4a108df0ebb68e9ea1073d53c14d8f897e43f21c (patch) | |
| tree | 69f855f8396bd7408a2047899c3eddc8aec22653 /src | |
| parent | 00071c976f9a16b5684697d10b086fc1b0be7145 (diff) | |
| download | emacs-4a108df0ebb68e9ea1073d53c14d8f897e43f21c.tar.gz emacs-4a108df0ebb68e9ea1073d53c14d8f897e43f21c.zip | |
Fix check for whether frames fit into gif images
* src/image.c (gif_load): Really check all frames that they fit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/image.c b/src/image.c index b6edcf96a0b..3afb8324078 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -8937,16 +8937,19 @@ gif_load (struct frame *f, struct image *img) | |||
| 8937 | 8937 | ||
| 8938 | /* Check that the selected subimages fit. It's not clear whether | 8938 | /* Check that the selected subimages fit. It's not clear whether |
| 8939 | the GIF spec requires this, but Emacs can crash if they don't fit. */ | 8939 | the GIF spec requires this, but Emacs can crash if they don't fit. */ |
| 8940 | for (j = 0; j <= idx; ++j) | 8940 | for (j = 0; j < gif->ImageCount; ++j) |
| 8941 | { | 8941 | { |
| 8942 | struct SavedImage *subimage = gif->SavedImages + j; | 8942 | struct SavedImage *subimage = gif->SavedImages + j; |
| 8943 | int subimg_width = subimage->ImageDesc.Width; | 8943 | int subimg_width = subimage->ImageDesc.Width; |
| 8944 | int subimg_height = subimage->ImageDesc.Height; | 8944 | int subimg_height = subimage->ImageDesc.Height; |
| 8945 | int subimg_top = subimage->ImageDesc.Top; | 8945 | int subimg_top = subimage->ImageDesc.Top; |
| 8946 | int subimg_left = subimage->ImageDesc.Left; | 8946 | int subimg_left = subimage->ImageDesc.Left; |
| 8947 | if (! (subimg_width >= 0 && subimg_height >= 0 | 8947 | if (subimg_width < 0 |
| 8948 | && 0 <= subimg_top && subimg_top <= height - subimg_height | 8948 | || subimg_height < 0 |
| 8949 | && 0 <= subimg_left && subimg_left <= width - subimg_width)) | 8949 | || subimg_top < 0 |
| 8950 | || subimg_left < 0 | ||
| 8951 | || subimg_top + subimg_height > height | ||
| 8952 | || subimg_left + subimg_width > width) | ||
| 8950 | { | 8953 | { |
| 8951 | image_error ("Subimage does not fit in image"); | 8954 | image_error ("Subimage does not fit in image"); |
| 8952 | goto gif_error; | 8955 | goto gif_error; |