changeset 414:6f88563ea26f

Avoid endless recursion if NaN passed to fromSeconds
author Chris Cannam
date Fri, 04 Sep 2015 13:47:25 +0100
parents 3ee97caa8fb6
children 1522e2f6d700
files src/vamp-sdk/RealTime.cpp
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/vamp-sdk/RealTime.cpp	Fri Sep 04 12:37:58 2015 +0100
+++ b/src/vamp-sdk/RealTime.cpp	Fri Sep 04 13:47:25 2015 +0100
@@ -92,7 +92,10 @@
 RealTime
 RealTime::fromSeconds(double sec)
 {
-    if (sec >= 0) {
+    if (sec != sec) { // NaN
+        cerr << "ERROR: NaN/Inf passed to Vamp::RealTime::fromSeconds" << endl;
+        return RealTime::zeroTime;
+    } else if (sec >= 0) {
         return RealTime(int(sec), int((sec - int(sec)) * ONE_BILLION + 0.5));
     } else {
         return -fromSeconds(-sec);