summaryrefslogtreecommitdiff
path: root/oss-fuzz
diff options
context:
space:
mode:
authorMartijn van Beurden <mvanb1@gmail.com>2022-05-19 11:12:15 +0200
committerMartijn van Beurden <mvanb1@gmail.com>2022-05-19 20:22:09 +0200
commit74b093f6e16b8a950a2b52256a1c162c1e85c380 (patch)
tree09f832aa292f2a3798daea9e018bea1be0927380 /oss-fuzz
parent383b77fa08dad82e670779871244851c9dd5f19c (diff)
downloadflac-74b093f6e16b8a950a2b52256a1c162c1e85c380.tar.gz
Fix initialization of encoder fuzzer (v1)
The encoder fuzzer initialized before setting up. This is now swapped without upsetting the way the datasource is queried
Diffstat (limited to 'oss-fuzz')
-rw-r--r--oss-fuzz/fuzzer_encoder.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/oss-fuzz/fuzzer_encoder.cc b/oss-fuzz/fuzzer_encoder.cc
index 03c350ef..f38bdf26 100644
--- a/oss-fuzz/fuzzer_encoder.cc
+++ b/oss-fuzz/fuzzer_encoder.cc
@@ -62,23 +62,15 @@ namespace FLAC {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fuzzing::datasource::Datasource ds(data, size);
FLAC::Encoder::FuzzerStream encoder(ds);
+ bool use_ogg;
const int channels = 2;
encoder.set_channels(channels);
encoder.set_bits_per_sample(16);
try {
- ::FLAC__StreamEncoderInitStatus ret;
- if ( ds.Get<bool>() ) {
- ret = encoder.init();
- } else {
- ret = encoder.init_ogg();
- }
-
- if ( ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK ) {
- goto end;
- }
+ use_ogg = ! ds.Get<bool>();
{
const bool res = encoder.set_streamable_subset(ds.Get<bool>());
@@ -146,6 +138,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fuzzing::memory::memory_test(res);
}
+ {
+ ::FLAC__StreamEncoderInitStatus ret;
+ if ( !use_ogg ) {
+ ret = encoder.init();
+ } else {
+ ret = encoder.init_ogg();
+ }
+
+ if ( ret != FLAC__STREAM_ENCODER_INIT_STATUS_OK ) {
+ goto end;
+ }
+ }
+
+
while ( ds.Get<bool>() ) {
{
auto dat = ds.GetVector<FLAC__int32>();