blob: df5a510bb5528820e445ae67c4a7ad04331bd513 (
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
|
/**
* Test that failure to convert to JPEG returns NULL
*
* We are creating an image, set its width to zero, and pass this image to
* `gdImageJpegPtr()` 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 src, dst;
int size;
src = gdImageCreateTrueColor(1, 10);
gdTestAssert(src != NULL);
src->sx = 0; /* this hack forces gdImageJpegPtr() to fail */
dst = gdImageJpegPtr(src, &size, 0);
gdTestAssert(dst == NULL);
gdImageDestroy(src);
return gdNumFailures();
}
|