[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with mex file
From: |
John W. Eaton |
Subject: |
Re: Problem with mex file |
Date: |
Mon, 11 Sep 2006 10:43:15 -0400 |
On 9-Sep-2006, frank wang wrote:
| Hi, John,
|
| It is strange. The problem codes are:
| if (nRhs > 1)
| {
| px = mxGetPr(pRhs[1]);
| for (n=0; n<mxGetM(pRhs[1])*mxGetN(pRhs[1]); n++)
| pScl[n] = (unsigned)px[n];
| px = mxGetPr(pRhs[2]);
| pScl[5] = (unsigned)px[0];
| px = mxGetPr(pRhs[3]);
| pScl[6] = (unsigned)px[0];
| }
| where pScl is initialized to {0 0 0 0 0 0}.
It looks like this code is making an invalid assumption. If nRhs > 1,
then it is certainly OK to access pRhs[1] but it may not be valid to
access pRhs[2] (these are 0-based indices). So to access pRhs[N], you
need to ensure that nRhs > N.
jwe