summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2022-02-01 22:58:21 +0700
committerPierre Joye <pierre.php@gmail.com>2022-02-01 22:58:21 +0700
commit09d5a6ad83888a352fc6058a478e7e1b1d48a7f6 (patch)
tree7d69edf292c5c67028e05869a27d853eeb06868b
parent95c6185b3751a7b3d73093e1d9b67bb00a577cd2 (diff)
downloadlibgd-09d5a6ad83888a352fc6058a478e7e1b1d48a7f6.tar.gz
partial #818, fix again that logic. I need to find something more generic and convenient to handle errors, assert and free used resources on fail assert
-rw-r--r--tests/tiff/tiff_invalid_read.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/tiff/tiff_invalid_read.c b/tests/tiff/tiff_invalid_read.c
index 3c87bcf..3fd2a63 100644
--- a/tests/tiff/tiff_invalid_read.c
+++ b/tests/tiff/tiff_invalid_read.c
@@ -41,7 +41,6 @@ static size_t read_test_file(char **buffer, char *basename)
{
char *filename;
FILE *fp;
-
size_t exp_size = 0, act_size = -1;
filename = gdTestFilePath2("tiff", basename);
@@ -54,7 +53,7 @@ static size_t read_test_file(char **buffer, char *basename)
}
exp_size = ftell(fp);
- if (!gdTestAssert(exp_size > 0)) {
+ if (exp_size <= 0) {
gdTestAssert(1==0); // only increase num failures used as return values in main
goto fail2;
}
@@ -65,12 +64,13 @@ static size_t read_test_file(char **buffer, char *basename)
}
*buffer = malloc(exp_size);
- if (gdTestAssert(*buffer != NULL)) {
+ if (*buffer != NULL) {
act_size = fread(*buffer, sizeof(**buffer), exp_size, fp);
gdTestAssert(act_size == exp_size);
+ } else {
+ gdTestAssert(0);
}
-
fail2:
fclose(fp);
fail3: