mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-02 00:22:10 -05:00
Check for lower/upper GetDouble/GetInt limits
This commit is contained in:
parent
b2fc560701
commit
dcba7c535d
|
|
@ -1,6 +1,7 @@
|
|||
#include "math-helpers.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <exprtk.hpp>
|
||||
#include <random>
|
||||
|
||||
|
|
@ -41,7 +42,8 @@ std::optional<double> 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<int> 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 {};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user