summaryrefslogtreecommitdiff
path: root/tests/gdtransformaffinecopy/github_bug_00583.c
blob: 6b0fd53d1cac0d0d17364697cc37a54d4c2b8fb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * Test that a zero determinant matrix causes gdTransformAffineCopy() to fail
 *
 * See <https://github.com/libgd/libgd/issues/583>
 */

#include "gd.h"
#include "gdtest.h"


int main()
{
    gdImagePtr src, dst;
    gdRect rect = {0, 0, 8, 8};
    double matrix[] = {1, 1, 1, 1, 1, 1};
    int white;
    int res;

    src = gdImageCreateTrueColor(8, 8);
    gdTestAssert(src != NULL);
    dst = gdImageCreateTrueColor(8, 8);
    gdTestAssert(dst != NULL);
    white = gdImageColorAllocate(src, 255, 255, 255);
    gdImageFilledRectangle(src, 0, 0, 7, 7, white);
    res = gdTransformAffineCopy(dst, 0, 0, src, &rect, matrix);
    gdTestAssert(res == GD_FALSE);
    gdImageDestroy(dst);
    gdImageDestroy(src);
    return gdNumFailures();
}