Add abort on encoding error that should not happen

This commit lets the following errors trigger an abort:
- FLAC__STREAM_ENCODER_OGG_ERROR
- FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR
- FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA
- FLAC__STREAM_ENCODER_IO_ERROR
- FLAC__STREAM_ENCODER_FRAMING_ERROR
- FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR

FLAC__STREAM_ENCODER_CLIENT_ERROR does not trigger an abort because
it is used to signal invalid input. FLAC__STREAM_ENCODER_UNINITIALIZED
does not trigger an abort because init fails when invalid parameters
are given
This commit is contained in:
Martijn van Beurden 2022-05-10 19:59:53 +02:00
parent 6122337f73
commit 87a5f3e952
1 changed files with 7 additions and 0 deletions

View File

@ -238,6 +238,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
}
}
if(FLAC__stream_encoder_get_state(encoder) != FLAC__STREAM_ENCODER_OK &&
FLAC__stream_encoder_get_state(encoder) != FLAC__STREAM_ENCODER_UNINITIALIZED &&
FLAC__stream_encoder_get_state(encoder) != FLAC__STREAM_ENCODER_CLIENT_ERROR){
fprintf(stderr,"-----\nERROR: stream encoder returned %s\n-----\n",FLAC__stream_encoder_get_resolved_state_string(encoder));
abort();
}
FLAC__stream_encoder_finish(encoder);
/* now that encoding is finished, the metadata can be freed */