From bf8c57c669a71077844c8885f47b861a0b9141b5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 9 May 2009 09:21:14 -0400 Subject: [PATCH] Fixed compiler choosing whether to emit stradjust.pri on dynamic arrays based on uninitialized memory (bug 3810, r=fyren,pred, a12=blocking). --- sourcepawn/compiler/sc1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index af7c1ef9..5df0aea5 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -2303,12 +2303,13 @@ static int declloc(int fstatic) if (matchtoken(']')) { idxtag[numdim] = 0; dim[numdim] = 0; - numdim++; + numdim++; continue; } dim_ident = doexpr2(TRUE,FALSE,FALSE,FALSE,&idxtag[numdim],&dim_sym,0,&dim_val); if (dim_ident == iVARIABLE || dim_ident == iEXPRESSION || dim_ident == iARRAYCELL) { all_constant = 0; + dim[numdim] = 0; } else if (dim_ident == iCONSTEXPR) { dim[numdim] = dim_val.constval; /* :TODO: :URGENT: Make sure this still works */ @@ -2323,7 +2324,7 @@ static int declloc(int fstatic) error(29); /* invalid expression, assumed 0 */ } numdim++; - needtoken(']'); + needtoken(']'); } while (matchtoken('[')); if (all_constant) { /* Change the last dimension to be based on chars instead if we have a string */ @@ -2335,7 +2336,7 @@ static int declloc(int fstatic) ident = iARRAY; stgdel(_index, _code); } else { - if (tag == pc_tag_string && numdim && dim[numdim-1]) { + if (tag == pc_tag_string && numdim) { stradjust(sPRI); } pushreg(sPRI);