From dcba7c535d8099778217ba762a86760d819d89bd Mon Sep 17 00:00:00 2001 From: Przemek Pawlas <3606072+Destroy666x@users.noreply.github.com> Date: Thu, 22 Feb 2024 19:48:49 +0100 Subject: [PATCH] Check for lower/upper GetDouble/GetInt limits --- lib/utils/math-helpers.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils/math-helpers.cpp b/lib/utils/math-helpers.cpp index f7d5acd2..6da048f4 100644 --- a/lib/utils/math-helpers.cpp +++ b/lib/utils/math-helpers.cpp @@ -1,6 +1,7 @@ #include "math-helpers.hpp" #include "obs-module-helper.hpp" +#include #include #include @@ -41,7 +42,8 @@ std::optional GetDouble(const std::string &str) { char *end = nullptr; double value = std::strtod(str.c_str(), &end); - if (end != str.c_str() && *end == '\0' && value != HUGE_VAL) { + if (end != str.c_str() && *end == '\0' && value != HUGE_VAL && + value != -HUGE_VAL) { return value; } return {}; @@ -51,7 +53,8 @@ std::optional GetInt(const std::string &str) { char *end = nullptr; int value = std::strtol(str.c_str(), &end, 10); - if (end != str.c_str() && *end == '\0') { + if (end != str.c_str() && *end == '\0' && value != INT_MAX && + value != INT_MIN) { return value; } return {};