From d22a49d2d6dc4bfc67bce71c7652013704ed304a Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 14 2020 07:02:18 +0000 Subject: Apply patch gd-2.2.5-null-pointer.patch patch_name: gd-2.2.5-null-pointer.patch present_in_specfile: true --- diff --git a/src/gd.c b/src/gd.c index 7f0a258..45ee762 100755 --- a/src/gd.c +++ b/src/gd.c @@ -2855,14 +2855,6 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) { } } - if (src->styleLength > 0) { - dst->styleLength = src->styleLength; - dst->stylePos = src->stylePos; - for (i = 0; i < src->styleLength; i++) { - dst->style[i] = src->style[i]; - } - } - dst->interlace = src->interlace; dst->alphaBlendingFlag = src->alphaBlendingFlag; @@ -2897,6 +2889,7 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) { if (src->style) { gdImageSetStyle(dst, src->style, src->styleLength); + dst->stylePos = src->stylePos; } for (i = 0; i < gdMaxColors; i++) { diff --git a/tests/gdimageclone/style.c b/tests/gdimageclone/style.c new file mode 100644 index 0000000..c2b246e --- /dev/null +++ b/tests/gdimageclone/style.c @@ -0,0 +1,30 @@ +/** + * Cloning an image should exactly reproduce all style related data + */ + + +#include +#include "gd.h" +#include "gdtest.h" + + +int main() +{ + gdImagePtr im, clone; + int style[] = {0, 0, 0}; + + im = gdImageCreate(8, 8); + gdImageSetStyle(im, style, sizeof(style)/sizeof(style[0])); + + clone = gdImageClone(im); + gdTestAssert(clone != NULL); + + gdTestAssert(clone->styleLength == im->styleLength); + gdTestAssert(clone->stylePos == im->stylePos); + gdTestAssert(!memcmp(clone->style, im->style, sizeof(style)/sizeof(style[0]))); + + gdImageDestroy(clone); + gdImageDestroy(im); + + return gdNumFailures(); +}