summaryrefslogtreecommitdiff
path: root/tests/gd2
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2022-02-01 15:09:01 +0700
committerGitHub <noreply@github.com>2022-02-01 15:09:01 +0700
commit167ea1f4f0003f3e9f7ca1e586189e99cf33d47f (patch)
treea21a237b619b048e0c6d88388744cf9f029d47ae /tests/gd2
parent3d760c2c213f7a63dbe13792262406177cd9738a (diff)
downloadlibgd-167ea1f4f0003f3e9f7ca1e586189e99cf33d47f.tar.gz
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
Diffstat (limited to 'tests/gd2')
-rw-r--r--tests/gd2/gd2_read.c5
-rw-r--r--tests/gd2/gd2_read_corrupt.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/tests/gd2/gd2_read.c b/tests/gd2/gd2_read.c
index 9f2b808..be625c3 100644
--- a/tests/gd2/gd2_read.c
+++ b/tests/gd2/gd2_read.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include "gdtest.h"
-int main(int argc, char *argv[])
+int main()
{
int error = 0, i = 0;
gdImagePtr im, exp;
@@ -27,6 +27,9 @@ int main(int argc, char *argv[])
return 1;
}
im = gdImageCreateFromGd2(fp);
+ if (gdTestAssert(im == NULL)) {
+ gdTestErrorMsg("failed, cannot decode file: %s\n", path[0]);
+ }
fclose(fp);
if (path_exp[i] != NULL) {
diff --git a/tests/gd2/gd2_read_corrupt.c b/tests/gd2/gd2_read_corrupt.c
index 7afc303..a636316 100644
--- a/tests/gd2/gd2_read_corrupt.c
+++ b/tests/gd2/gd2_read_corrupt.c
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include "gdtest.h"
-int main(int argc, char *argv[])
+int main()
{
gdImagePtr im;
FILE *fp;