From f4906bf100acb8c5875196b7c2306effdd6a091d Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 28 Apr 2006 11:47:35 +0000 Subject: [PATCH] Fix a possible segfault. --- Makefile | 2 +- pitch.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b7cc597..5cbb2cc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CXXFLAGS=-O2 -Wall +CXXFLAGS=-g -Wall CPPFLAGS= all: pitch diff --git a/pitch.cpp b/pitch.cpp index 1c272f1..97238f5 100644 --- a/pitch.cpp +++ b/pitch.cpp @@ -234,6 +234,9 @@ std::pair 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 peak = interpolate_peak(in[best_bin - 1], in[best_bin], -- 2.39.2