summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-09-01 14:01:53 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-09-06 12:04:06 +0200
commit20caaffa82f701ef52900f4504227f88320d227f (patch)
tree6f89ebe5ca993cf1efff5ccacd2469c7cc0bbeea /sc/source
parent08b0c3b848b8f2bd667fad00068f3c828c709ef5 (diff)
check parameter count in opencl logical functions
Change-Id: If77bd146bd9eafd54afa1b82203d378ab9cd26d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139197 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/opencl/op_logical.cxx5
-rw-r--r--sc/source/core/opencl/opbase.hxx10
2 files changed, 13 insertions, 2 deletions
diff --git a/sc/source/core/opencl/op_logical.cxx b/sc/source/core/opencl/op_logical.cxx
index 969b63d0ee7b..1fa21e8250e6 100644
--- a/sc/source/core/opencl/op_logical.cxx
+++ b/sc/source/core/opencl/op_logical.cxx
@@ -18,6 +18,7 @@ namespace sc::opencl {
void OpAnd::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
+ CHECK_PARAMETER_COUNT_MIN( 1 );
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (size_t i = 0; i < vSubArguments.size(); i++)
@@ -103,6 +104,7 @@ void OpAnd::GenSlidingWindowFunction(outputstream &ss,
void OpOr::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
+ CHECK_PARAMETER_COUNT_MIN( 1 );
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (size_t i = 0; i < vSubArguments.size(); i++)
@@ -182,6 +184,7 @@ void OpOr::GenSlidingWindowFunction(outputstream &ss,
void OpNot::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
+ CHECK_PARAMETER_COUNT( 1, 1 );
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (size_t i = 0; i < vSubArguments.size(); i++)
@@ -219,6 +222,7 @@ void OpNot::GenSlidingWindowFunction(outputstream &ss,
void OpXor::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
+ CHECK_PARAMETER_COUNT_MIN( 1 );
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (size_t i = 0; i < vSubArguments.size(); i++)
@@ -298,6 +302,7 @@ void OpXor::GenSlidingWindowFunction(outputstream &ss,
void OpIf::GenSlidingWindowFunction(outputstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
+ CHECK_PARAMETER_COUNT( 1, 3 );
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (size_t i = 0; i < vSubArguments.size(); i++)
diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx
index 4262da8c35da..c56c02c855a3 100644
--- a/sc/source/core/opencl/opbase.hxx
+++ b/sc/source/core/opencl/opbase.hxx
@@ -70,14 +70,20 @@ public:
int const mLineNumber;
};
-// Helper macro to be used in code emitting OpenCL code for Calc functions.
-// Requires the vSubArguments parameter.
+// Helper macros to be used in code emitting OpenCL code for Calc functions.
+// Require the vSubArguments parameter.
#define CHECK_PARAMETER_COUNT(min, max) \
do { \
const int count = vSubArguments.size(); \
if( count < ( min ) || count > ( max )) \
throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
} while( false )
+#define CHECK_PARAMETER_COUNT_MIN(min) \
+ do { \
+ const int count = vSubArguments.size(); \
+ if( count < ( min )) \
+ throw InvalidParameterCount( count, __FILE__, __LINE__ ); \
+ } while( false )
typedef std::shared_ptr<FormulaTreeNode> FormulaTreeNodeRef;