From c37780726d9a5d179fef30036378ffd2dd5a5e43 Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Mon, 27 Jun 2022 13:33:10 +0200 Subject: [PATCH] fix(VarHolder): limits check --- Foundation/include/Poco/Dynamic/VarHolder.h | 22 +++++++-------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Foundation/include/Poco/Dynamic/VarHolder.h b/Foundation/include/Poco/Dynamic/VarHolder.h index f6987b283a..16b99d0a15 100644 --- a/Foundation/include/Poco/Dynamic/VarHolder.h +++ b/Foundation/include/Poco/Dynamic/VarHolder.h @@ -410,16 +410,15 @@ class Foundation_API VarHolder template void checkUpperLimit(const F& from) const { - if ((sizeof(T) < sizeof(F)) && - (from > static_cast(std::numeric_limits::max()))) - { - throw RangeException("Value too large."); - } - else if (from > std::numeric_limits::max()) - { throw RangeException("Value too large."); - } + } + + template + void checkLowerLimit(const F& from) const + { + if (from < std::numeric_limits::min()) + throw RangeException("Value too small."); } template @@ -453,13 +452,6 @@ class Foundation_API VarHolder throw RangeException("Value too small."); } } - - template - void checkLowerLimit(const F& from) const - { - if (from < std::numeric_limits::min()) - throw RangeException("Value too small."); - } };