aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libarchive/libarchive/test/test_fuzz.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libarchive/libarchive/test/test_fuzz.c')
-rw-r--r--contrib/libarchive/libarchive/test/test_fuzz.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/contrib/libarchive/libarchive/test/test_fuzz.c b/contrib/libarchive/libarchive/test/test_fuzz.c
index 67aa1aca8d75..b70a415ac4ad 100644
--- a/contrib/libarchive/libarchive/test/test_fuzz.c
+++ b/contrib/libarchive/libarchive/test/test_fuzz.c
@@ -104,16 +104,19 @@ test_fuzz(const struct files *filesets)
}
if (!assert(size < buffsize)) {
free(rawimage);
+ rawimage = NULL;
continue;
}
} else {
for (i = 0; filesets[n].names[i] != NULL; ++i)
{
tmp = slurpfile(&size, filesets[n].names[i]);
- char *newraw = (char *)realloc(rawimage, oldsize + size);
+ char *newraw = realloc(rawimage, oldsize + size);
if (!assert(newraw != NULL))
{
free(rawimage);
+ rawimage = NULL;
+ free(tmp);
continue;
}
rawimage = newraw;
@@ -123,14 +126,21 @@ test_fuzz(const struct files *filesets)
free(tmp);
}
}
- if (size == 0)
+ if (size == 0) {
+ free(rawimage);
+ rawimage = NULL;
continue;
+ }
image = malloc(size);
assert(image != NULL);
if (image == NULL) {
free(rawimage);
+ rawimage = NULL;
return;
}
+
+ assert(rawimage != NULL);
+
srand((unsigned)time(NULL));
for (i = 0; i < 1000; ++i) {
@@ -162,6 +172,7 @@ test_fuzz(const struct files *filesets)
Sleep(100);
#endif
}
+ assert(f != NULL);
assertEqualInt((size_t)size, fwrite(image, 1, (size_t)size, f));
fclose(f);
@@ -195,7 +206,7 @@ test_fuzz(const struct files *filesets)
archive_read_close(a);
}
archive_read_free(a);
-}
+ }
free(image);
free(rawimage);
}