Remove files generated during fuzzing of flac tool

CI-Fuzz occassionally runs out of disk space, and there might be
other problems (coverage suddenly vanishing for example) related
to disk space issues. This commit should make sure all files
generated by the flac tool are removed as soon as they are closed.
This commit is contained in:
Martijn van Beurden 2023-04-21 20:40:53 +02:00
parent 9bbdb6be6d
commit 5008827b64
3 changed files with 12 additions and 0 deletions

View File

@ -245,5 +245,8 @@ FLAC__bool dump_stats(const subframe_stats_t *stats, const char *filename)
fprintf(outfile, "pause -1 'waiting...'\n");
fclose(outfile);
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
unlink(filename);
#endif
return true;
}

View File

@ -297,7 +297,11 @@ 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);
}
}

View File

@ -1626,6 +1626,11 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a
ret = 1;
}
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
/* Always delete output file when fuzzing */
flac_unlink(e->outfilename);
#endif
EncoderSession_destroy(e);
return ret;