Fix a buffer overrun that was introduced in the splitting.
authorsgunderson@bigfoot.com <>
Wed, 20 Dec 2006 02:04:29 +0000 (03:04 +0100)
committersgunderson@bigfoot.com <>
Wed, 20 Dec 2006 02:04:29 +0000 (03:04 +0100)
pitchdetector.cpp

index 71e5875..cf0abe0 100644 (file)
@@ -38,7 +38,7 @@ PitchDetector::~PitchDetector()
 std::pair<double, double> PitchDetector::detect_pitch(short *buf)
 {
        unsigned buf_len = fft_length / pad_factor / overlap;
 std::pair<double, double> PitchDetector::detect_pitch(short *buf)
 {
        unsigned buf_len = fft_length / pad_factor / overlap;
-       memmove(in, in + buf_len, (fft_length - buf_len) * sizeof(double));
+       memmove(in, in + buf_len, (fft_length / pad_factor - buf_len) * sizeof(double));
        
        for (unsigned i = 0; i < buf_len; ++i)
                in[i + (fft_length / pad_factor - buf_len)] = double(buf[i]);
        
        for (unsigned i = 0; i < buf_len; ++i)
                in[i + (fft_length / pad_factor - buf_len)] = double(buf[i]);