From 176f328ab001309bda3e383f9d0de5f6a2e464d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 9 Jan 2020 09:26:27 +0100
Subject: [PATCH] mjdgges MEX: enforce exactly 7 output arguments

The code may crash if less are provided.
---
 mex/sources/mjdgges/mjdgges.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mex/sources/mjdgges/mjdgges.cc b/mex/sources/mjdgges/mjdgges.cc
index b3873a90af..1fe92a1a46 100644
--- a/mex/sources/mjdgges/mjdgges.cc
+++ b/mex/sources/mjdgges/mjdgges.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006-2019 Dynare Team
+ * Copyright © 2006-2020 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -38,8 +38,8 @@ mexFunction(int nlhs, mxArray *plhs[],
             int nrhs, const mxArray *prhs[])
 {
   /* Check for proper number of arguments */
-  if (nrhs < 2 || nrhs > 4 || nlhs == 0 || nlhs > 7)
-    DYN_MEX_FUNC_ERR_MSG_TXT("MJDGGES: takes 2, 3 or 4 input arguments and between 1 and 7 output arguments.");
+  if (nrhs < 2 || nrhs > 4 || nlhs != 7)
+    DYN_MEX_FUNC_ERR_MSG_TXT("MJDGGES: takes 2, 3 or 4 input arguments and exactly 7 output arguments.");
 
   /* Check that A and B are real matrices of the same dimension.*/
   size_t m1 = mxGetM(prhs[0]);
-- 
GitLab