From b0e29c8c239a98b56b2857c82a41c5f8aaabad31 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 17 Jun 2021 23:21:29 -0400 Subject: [PATCH] Fix crash when doing sim.ambientAirTemp(0/0) --- src/Misc.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Misc.h b/src/Misc.h index 5731a1c79..358079a38 100644 --- a/src/Misc.h +++ b/src/Misc.h @@ -1,6 +1,7 @@ #ifndef UTILS_H #define UTILS_H #include "Config.h" +#include #include #include #include @@ -43,9 +44,12 @@ inline unsigned clamp_flt(float f, float min, float max) inline float restrict_flt(float f, float min, float max) { - if (fmax) + if (f < min) + return min; + if (f > max) return max; return f; }