2013-02-28 23:53:11 -08:00
|
|
|
#include "gd.h"
|
2007-10-02 02:01:53 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "gdtest.h"
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
gdImagePtr im;
|
|
|
|
FILE *fp;
|
2016-05-17 20:32:16 -07:00
|
|
|
char *file;
|
2016-06-03 17:31:02 -07:00
|
|
|
int error = 0;
|
2007-10-02 02:01:53 -07:00
|
|
|
|
|
|
|
im = gdImageCreateTrueColor(100, 100);
|
|
|
|
|
2013-04-22 14:08:20 -07:00
|
|
|
if (im == NULL) {
|
|
|
|
gdTestErrorMsg("Cannot create image.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-02 02:01:53 -07:00
|
|
|
gdImageFill(im, 0, 0, 0xffffff);
|
|
|
|
gdImageFill(im, 0, 0, 0xffffff);
|
|
|
|
|
2016-05-17 20:32:16 -07:00
|
|
|
file = gdTestTempFile("bug00002_1.png");
|
|
|
|
fp = fopen(file, "wb");
|
Fix tests based on coverity reports (#819)
* Partial #818, unused arg
* Partial #818, init var
* partail #818, fix va_args usage
* partail #818, handle f* calls and avoid possible call to malloc with negative values
* partail #818, prevent double free
* partail #818, resource leak if test fail
* partail #818, null deref fix
* partail #818, avoid double free on fp failure
* Partial #818, fix error msg
* Partial #818, leak on error
* Partial #818, null deref
* Partial #818, avoid possible negative index on failure
* partial #818, does not free if we return if requested new size overflow
* partial #818, avoid double free, free where the alloc happened
2022-02-01 00:09:01 -08:00
|
|
|
|
2013-04-22 14:08:20 -07:00
|
|
|
if (fp == NULL) {
|
2016-05-17 20:32:16 -07:00
|
|
|
gdTestErrorMsg("Cannot create image from <%s>\n", file);
|
Fix tests based on coverity reports (#819)
* Partial #818, unused arg
* Partial #818, init var
* partail #818, fix va_args usage
* partail #818, handle f* calls and avoid possible call to malloc with negative values
* partail #818, prevent double free
* partail #818, resource leak if test fail
* partail #818, null deref fix
* partail #818, avoid double free on fp failure
* Partial #818, fix error msg
* Partial #818, leak on error
* Partial #818, null deref
* Partial #818, avoid possible negative index on failure
* partial #818, does not free if we return if requested new size overflow
* partial #818, avoid double free, free where the alloc happened
2022-02-01 00:09:01 -08:00
|
|
|
free(file);
|
2013-04-22 14:08:20 -07:00
|
|
|
gdImageDestroy(im);
|
|
|
|
return 1;
|
|
|
|
}
|
Fix tests based on coverity reports (#819)
* Partial #818, unused arg
* Partial #818, init var
* partail #818, fix va_args usage
* partail #818, handle f* calls and avoid possible call to malloc with negative values
* partail #818, prevent double free
* partail #818, resource leak if test fail
* partail #818, null deref fix
* partail #818, avoid double free on fp failure
* Partial #818, fix error msg
* Partial #818, leak on error
* Partial #818, null deref
* Partial #818, avoid possible negative index on failure
* partial #818, does not free if we return if requested new size overflow
* partial #818, avoid double free, free where the alloc happened
2022-02-01 00:09:01 -08:00
|
|
|
free(file);
|
2013-04-03 05:23:11 -07:00
|
|
|
gdImagePng(im,fp);
|
2007-10-02 02:01:53 -07:00
|
|
|
fclose(fp);
|
|
|
|
|
2016-06-03 17:31:02 -07:00
|
|
|
if (!gdAssertImageEqualsToFile("gdimagefill/bug00002_1_exp.png", im))
|
|
|
|
error = 1;
|
2007-10-02 02:01:53 -07:00
|
|
|
|
2013-04-03 05:23:11 -07:00
|
|
|
gdImageDestroy(im);
|
2013-04-22 14:08:20 -07:00
|
|
|
|
2016-06-03 17:31:02 -07:00
|
|
|
return error;
|
2007-10-02 02:01:53 -07:00
|
|
|
}
|