Merge pull request #736 from libgd/bug/415

Fix #415, Assuming TopOfs and LeftOfs zero, we can safely skip any (x…
master
Pierre Joye 2021-08-31 18:48:20 +07:00 committed by GitHub
commit 9251cd60d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View File

@ -745,6 +745,8 @@ break_top:
/* Then the bottom row */
for (y = tim->sy - 1; y > min_y; --y) {
for (x = 0; x < tim->sx; ++x) {
if (!gdImageBoundsSafe(prev_tim, x,y))
continue;
if (!comparewithmap
(prev_tim, tim,
prev_tim->pixels[y][x],
@ -766,6 +768,8 @@ break_bot:
/* left side */
for (x = 0; x < min_x; ++x) {
for (y = min_y; y <= max_y; ++y) {
if (!gdImageBoundsSafe(prev_tim, x,y))
continue;
if (!comparewithmap
(prev_tim, tim,
prev_tim->pixels[y][x],
@ -781,6 +785,8 @@ break_left:
/* right side */
for (x = tim->sx - 1; x > max_x; --x) {
for (y = min_y; y <= max_y; ++y) {
if (!gdImageBoundsSafe(prev_tim, x,y))
continue;
if (!comparewithmap
(prev_tim, tim,
prev_tim->pixels[y][x],

View File

@ -11,6 +11,7 @@ LIST(APPEND TESTS_FILES
bug00006
bug00060
gif_im2im
bug00415
)
IF(PNG_FOUND)

27
tests/gif/bug00415.c Normal file
View File

@ -0,0 +1,27 @@
#include <gd.h>
#include "gdtest.h"
int main()
{
gdImagePtr im1, im2;
im1 = gdImageCreate(100, 100);
gdImageColorAllocate(im1, 0, 0, 0);
im2 = gdImageCreate(10, 10);
gdImageColorAllocate(im2, 255, 255, 255);
FILE *fp = gdTestTempFp();
if (!fp) return 4;
gdImageGifAnimBegin(im1, fp, 0, 0);
gdImageGifAnimAdd(im1, fp, 1, 0, 0, 100, 1, NULL);
gdImageGifAnimAdd(im2, fp, 1, 0, 0, 100, 1, im1);
// replacing `im2` with `NULL` in the following line succeeds
gdImageGifAnimAdd(im1, fp, 1, 0, 0, 100, 1, im2);
gdImageGifAnimEnd(fp);
fclose(fp);
gdImageDestroy(im1);
gdImageDestroy(im2);
return 0;
}