]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
common : fix input buffer check (#1812)
authorGeorgi Gerganov <redacted>
Sat, 27 Jan 2024 15:33:09 +0000 (17:33 +0200)
committerGitHub <redacted>
Sat, 27 Jan 2024 15:33:09 +0000 (17:33 +0200)
examples/common.cpp

index 8404e00e09e6e36383a2b4234c842ed39bf2b1ab..548156ecbc0a27ed0760e404f20220fc1e2cf988 100644 (file)
@@ -639,7 +639,7 @@ bool read_wav(const std::string & fname, std::vector<float>& pcmf32, std::vector
 
         fprintf(stderr, "%s: read %zu bytes from stdin\n", __func__, wav_data.size());
     }
-    else if (fname.size() > 256 || fname.size() > 40 && fname.substr(0, 4) == "RIFF" && fname.substr(8, 4) == "WAVE") {
+    else if (fname.size() > 256 && (fname.substr(0, 4) == "RIFF" || fname.substr(8, 4) == "WAVE")) {
         if (drwav_init_memory(&wav, fname.c_str(), fname.size(), nullptr) == false) {
             fprintf(stderr, "error: failed to open WAV file from fname buffer\n");
             return false;