]> git.sesse.net Git - pitch/commitdiff
Fix a possible segfault.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Apr 2006 11:47:35 +0000 (11:47 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Apr 2006 11:47:35 +0000 (11:47 +0000)
Makefile
pitch.cpp

index b7cc597be9f285dba69ba3eaa887968f899352c1..5cbb2cc4b1e087ac9573b10fa79dc7267c79b070 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CXXFLAGS=-O2 -Wall
+CXXFLAGS=-g -Wall
 CPPFLAGS=
 
 all: pitch
index 1c272f1080b734bb7ae891611660edf6c915d2c0..97238f5f05b1a99113837029199f44434b1f220e 100644 (file)
--- a/pitch.cpp
+++ b/pitch.cpp
@@ -234,6 +234,9 @@ std::pair<double, double> find_peak(double *in, unsigned num_samples)
                }
        }
 
+       if (best_bin == 0 || best_bin == num_samples / 2) {
+               return std::make_pair(-1.0, 0.0);
+       }
        std::pair<double, double> peak = 
                interpolate_peak(in[best_bin - 1],
                                 in[best_bin],