fix #415, the same is needed in the other section, add test

master
Pierre Joye 2021-08-25 17:48:03 +07:00
parent 5771e976bd
commit 4cd5542152
3 changed files with 32 additions and 0 deletions

View File

@ -768,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],
@ -783,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;
}