summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests/png/bug00381_2.c
blob: 84c7bb156540e82d931c85b3c2c1ea76073ec1da (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
31
32
33
34
35
/**
 * Test that failure to convert to PNG returns NULL
 *
 * We are reading a palette image without any colors in the palette, and pass
 * this image to `gdImagePngPtr()` which is supposed to fail, and as such should
 * return NULL.
 *
 * See also <https://github.com/libgd/libgd/issues/381>
 */


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


int main()
{
    gdImagePtr im;
    FILE *fp;
    void *data;
    int size = 0;

    fp = gdTestFileOpen2("png", "bug00381_2.gd");
    gdTestAssert(fp != NULL);
    im = gdImageCreateFromGd(fp);
    gdTestAssert(im != NULL);
    fclose(fp);

    data = gdImagePngPtr(im, &size);
    gdTestAssert(data == NULL);

    gdImageDestroy(im);

    return gdNumFailures();
}