Merge pull request #225 from YashasSamaga/i220-fix
replaces dangling pointers in initarray with indexes
This commit is contained in:
commit
64563ff994
@ -2589,7 +2589,7 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
|
|||||||
int idx,idx_ellips,vidx,do_insert;
|
int idx,idx_ellips,vidx,do_insert;
|
||||||
int abortparse;
|
int abortparse;
|
||||||
int curlit;
|
int curlit;
|
||||||
cell *prev1=NULL,*prev2=NULL;
|
int prev1_idx=-1,prev2_idx=-1;
|
||||||
|
|
||||||
assert(cur>=0 && cur<numdim);
|
assert(cur>=0 && cur<numdim);
|
||||||
assert(startlit>=0);
|
assert(startlit>=0);
|
||||||
@ -2627,13 +2627,13 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
|
|||||||
/* found an ellipsis; fill up the rest of the array with a series
|
/* found an ellipsis; fill up the rest of the array with a series
|
||||||
* of one-dimensional arrays ("2d ellipsis")
|
* of one-dimensional arrays ("2d ellipsis")
|
||||||
*/
|
*/
|
||||||
if (prev1!=NULL) {
|
if (prev1_idx!=-1) {
|
||||||
for (idx_ellips=1; idx < dim[cur]; idx++, idx_ellips++) {
|
for (idx_ellips=1; idx < dim[cur]; idx++, idx_ellips++) {
|
||||||
for (vidx=0; vidx < dsize; vidx++) {
|
for (vidx=0; vidx < dsize; vidx++) {
|
||||||
if (prev2!=NULL)
|
if (prev2_idx!=-1)
|
||||||
litadd(prev1[vidx]+idx_ellips*(prev1[vidx]-prev2[vidx]));
|
litadd(litq[prev1_idx+vidx]+idx_ellips*(litq[prev1_idx+vidx]-litq[prev2_idx+vidx]));
|
||||||
else
|
else
|
||||||
litadd(prev1[vidx]);
|
litadd(litq[prev1_idx+vidx]);
|
||||||
} /* for */
|
} /* for */
|
||||||
append_constval(lastdim,itoh(idx),dsize,0);
|
append_constval(lastdim,itoh(idx),dsize,0);
|
||||||
} /* for */
|
} /* for */
|
||||||
@ -2641,8 +2641,8 @@ static cell initarray(int ident,int tag,int dim[],int numdim,int cur,
|
|||||||
} else
|
} else
|
||||||
error(41); /* invalid ellipsis, array size unknown */
|
error(41); /* invalid ellipsis, array size unknown */
|
||||||
} else {
|
} else {
|
||||||
prev2=prev1;
|
prev2_idx=prev1_idx;
|
||||||
prev1=&litq[litidx];
|
prev1_idx=litidx;
|
||||||
dsize=initvector(ident,tag,dim[cur+1],curlit,TRUE,enumroot,errorfound);
|
dsize=initvector(ident,tag,dim[cur+1],curlit,TRUE,enumroot,errorfound);
|
||||||
/* The final dimension may be variable length. We need to save the
|
/* The final dimension may be variable length. We need to save the
|
||||||
* lengths of the final dimensions in order to set the indirection
|
* lengths of the final dimensions in order to set the indirection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user