From: ulatekh Date: Tue, 9 Apr 2024 15:34:34 +0000 (-0700) Subject: common : fix file-handle leak in read_wav() (whisper/2026) X-Git-Tag: upstream/0.0.1642~770 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=15a3b2601cbdd4227b7f3fde0ed765a8ac0cf54b;p=pkg%2Fggml%2Fsources%2Fggml common : fix file-handle leak in read_wav() (whisper/2026) Now it cleans up in case of error. --- diff --git a/examples/common.cpp b/examples/common.cpp index fad9a7c2..2c0cdf08 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -676,21 +676,25 @@ bool read_wav(const std::string & fname, std::vector& pcmf32, std::vector if (wav.channels != 1 && wav.channels != 2) { fprintf(stderr, "%s: WAV file '%s' must be mono or stereo\n", __func__, fname.c_str()); + drwav_uninit(&wav); return false; } if (stereo && wav.channels != 2) { fprintf(stderr, "%s: WAV file '%s' must be stereo for diarization\n", __func__, fname.c_str()); + drwav_uninit(&wav); return false; } if (wav.sampleRate != COMMON_SAMPLE_RATE) { fprintf(stderr, "%s: WAV file '%s' must be %i kHz\n", __func__, fname.c_str(), COMMON_SAMPLE_RATE/1000); + drwav_uninit(&wav); return false; } if (wav.bitsPerSample != 16) { fprintf(stderr, "%s: WAV file '%s' must be 16-bit\n", __func__, fname.c_str()); + drwav_uninit(&wav); return false; }