Skip to content

Commit 6316d4d

Browse files
committed
OSS-Fuzz: Bail out immediately on decomp failure
Don't keep trying to decompress the same image if tj3Decompress*() has already thrown an error. Otherwise, if the image has an excessive number of scans, then each iteration of the loop will try to decompress up to the scan limit, which may cause the overall test to time out even if one iteration doesn't time out.
1 parent d743a2c commit 6316d4d

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

fuzz/decompress.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2021 D. R. Commander. All Rights Reserved.
2+
* Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -88,7 +88,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
8888
when using MemorySanitizer. */
8989
for (i = 0; i < w * h * tjPixelSize[pf]; i++)
9090
sum += dstBuf[i];
91-
}
91+
} else
92+
goto bailout;
9293

9394
free(dstBuf);
9495
dstBuf = NULL;

fuzz/decompress_yuv.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C)2021 D. R. Commander. All Rights Reserved.
2+
* Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are met:
@@ -90,7 +90,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
9090
when using MemorySanitizer. */
9191
for (i = 0; i < w * h * tjPixelSize[pf]; i++)
9292
sum += dstBuf[i];
93-
}
93+
} else
94+
goto bailout;
9495

9596
free(dstBuf);
9697
dstBuf = NULL;

0 commit comments

Comments
 (0)