From ad4ad64a8b0cd55b7c273f6a9ea097746f492b33 Mon Sep 17 00:00:00 2001 From: Yashas Date: Thu, 14 Jun 2018 21:54:49 +0530 Subject: [PATCH] check dimensions of uninitialized array declarations Fix for #314 --- source/compiler/sc1.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index 116a65e..09d25df 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -2490,17 +2490,21 @@ static void initials(int ident,int tag,cell *size,int dim[],int numdim, cell tablesize; int curlit=litidx; int err=0; + int i; if (!matchtoken('=')) { assert(ident!=iARRAY || numdim>0); - if (ident==iARRAY && dim[numdim-1]==0) { - /* declared as "myvar[];" which is senseless (note: this *does* make - * sense in the case of a iREFARRAY, which is a function parameter) - */ - error(9); /* array has zero length -> invalid size */ - } /* if */ if (ident==iARRAY) { assert(numdim>0 && numdim<=sDIMEN_MAX); + for (i=0; i invalid size */ + return; + } /* if */ + } /* for */ *size=calc_arraysize(dim,numdim,0); if (*size==(cell)CELL_MAX) { error(9); /* array is too big -> invalid size */