When FLAC__stream_encoder_set_verify is set to true and giving underestimated total sample count in FLAC__stream_encoder_set_total_samples_estimate, an encoder crashes at the end of a process (possibly in FLAC__stream_encoder_finish). The crash doesn't happen when verify is turned off.
See the code attached to reproduce the crash.
My investigation
Direct reason: buffer overflows in
append_to_verify_fifo_[interleaved_]Fundamental reason: decoder for verify may stop processing (and stop consuming FIFO) when total samples in STREAMINFO is a non-zero value, while encoder still continues to fill FIFO
Solution: force set total samples to zero when first write STREAMINFO in
FLAC__StreamEncoderInitStatusin case verify is enabledThis patch solves the problem.