Enable fuzzing of writing foreign metadata back on decoding

The output file was deleted before writing back foreign metadata
could take place, making that code always fail and not covered by
fuzzing
This commit is contained in:
Martijn van Beurden 2024-07-12 10:43:42 +02:00
parent 51e61ae99e
commit d48b689ae8
1 changed files with 5 additions and 3 deletions

View File

@ -304,10 +304,7 @@ void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred)
#endif
fclose(d->fout);
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Always delete output file when fuzzing */
if(error_occurred)
#endif
flac_unlink(d->outfilename);
}
}
@ -582,6 +579,11 @@ int DecoderSession_finish_ok(DecoderSession *d)
}
}
}
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Delete output file when fuzzing */
if(0 != d->fout && d->fout != stdout)
flac_unlink(d->outfilename);
#endif
return ok? 0 : 1;
}