scilab: fix crash (int typecheck)

This commit is contained in:
Simon Marchetto 2014-03-21 15:11:13 +01:00
commit 1711a7d15d

View file

@ -29,6 +29,7 @@ SWIG_SciDoubleOrInt32_AsInt(void *_pvApiCtx, SwigSciObject _iVar, int *_piValue,
} }
if (iType == sci_ints) { if (iType == sci_ints) {
if (_piValue) {
int iPrec = 0; int iPrec = 0;
int *piData = NULL; int *piData = NULL;
@ -52,10 +53,11 @@ SWIG_SciDoubleOrInt32_AsInt(void *_pvApiCtx, SwigSciObject _iVar, int *_piValue,
} }
*_piValue = *piData; *_piValue = *piData;
} }
}
else if (iType == sci_matrix) { else if (iType == sci_matrix) {
if (_piValue) {
double *pdData = NULL; double *pdData = NULL;
double dValue = 0.0f; double dValue = 0.0f;
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, &iRows, &iCols, &pdData); sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
if (sciErr.iErr) { if (sciErr.iErr) {
printError(&sciErr, 0); printError(&sciErr, 0);
@ -76,6 +78,7 @@ SWIG_SciDoubleOrInt32_AsInt(void *_pvApiCtx, SwigSciObject _iVar, int *_piValue,
} }
*_piValue = (int) dValue; *_piValue = (int) dValue;
} }
}
else { else {
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), _fname, _iVar); Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), _fname, _iVar);
return SWIG_TypeError; return SWIG_TypeError;