From 218bb1a15f3ceace1d6f35ea11da62c6e7cca8ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 5 Jul 2022 11:55:12 +0200
Subject: [PATCH] k_order_welfare MEX: check number of arguments

---
 mex/sources/k_order_welfare/k_order_welfare.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mex/sources/k_order_welfare/k_order_welfare.cc b/mex/sources/k_order_welfare/k_order_welfare.cc
index 5ae3552534..711e4d9006 100644
--- a/mex/sources/k_order_welfare/k_order_welfare.cc
+++ b/mex/sources/k_order_welfare/k_order_welfare.cc
@@ -87,6 +87,8 @@ extern "C" {
   void mexFunction(int nlhs, mxArray *plhs[],
                    int nrhs, const mxArray *prhs[])
   {
+    if (nlhs != 1 || nrhs != 3)
+      mexErrMsgTxt("Must have exactly 3 input arguments and 1 output argument");
 
     const mxArray *dr_mx = prhs[0];
     const mxArray *M_mx = prhs[1];
-- 
GitLab