From 325a746d9074d01e9869cb45b0602590f87bfb19 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Wed, 13 Aug 2014 15:38:50 +0200 Subject: [PATCH] Compiler: Fix issue with multidimensional array variable release. Imported from SM: https://bugs.alliedmods.net/show_bug.cgi?id=6100. --- AMBuildScript | 2 ++ compiler/libpc300/sc.h | 1 + compiler/libpc300/sc1.c | 2 +- compiler/libpc300/sc2.c | 12 +++++++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index cd1c5885..7b88dbdf 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -130,6 +130,8 @@ class AMXXConfig(object): '-Wno-uninitialized', '-Wno-unused', '-Wno-switch', + '-Wno-format', + '-Wno-format-security', '-m32', ] cfg.cxxflags += [ diff --git a/compiler/libpc300/sc.h b/compiler/libpc300/sc.h index ad1efb6c..012bcc6c 100755 --- a/compiler/libpc300/sc.h +++ b/compiler/libpc300/sc.h @@ -513,6 +513,7 @@ SC_FUNC void delete_consttable(constvalue *table); SC_FUNC symbol *add_constant(char *name,cell val,int vclass,int tag); SC_FUNC void exporttag(int tag); SC_FUNC void sc_attachdocumentation(symbol *sym); +SC_FUNC int get_actual_compound(symbol *sym); /* function prototypes in SC2.C */ #define PUSHSTK_P(v) { stkitem s_; s_.pv=(v); pushstk(s_); } diff --git a/compiler/libpc300/sc1.c b/compiler/libpc300/sc1.c index 4859c5c6..e45c78dd 100755 --- a/compiler/libpc300/sc1.c +++ b/compiler/libpc300/sc1.c @@ -4282,7 +4282,7 @@ static int testsymbols(symbol *root,int level,int testlabs,int testconst) int entry=FALSE; symbol *sym=root->next; - while (sym!=NULL && sym->compound>=level) { + while (sym != NULL && get_actual_compound(sym) >= level) { switch (sym->ident) { case iLABEL: if (testlabs) { diff --git a/compiler/libpc300/sc2.c b/compiler/libpc300/sc2.c index 3f18f0a4..bb48e71e 100755 --- a/compiler/libpc300/sc2.c +++ b/compiler/libpc300/sc2.c @@ -2417,6 +2417,16 @@ SC_FUNC void delete_symbol(symbol *root,symbol *sym) free_symbol(sym); } +SC_FUNC int get_actual_compound(symbol *sym) +{ + if (sym->ident == iARRAY || sym->ident == iREFARRAY) { + while (sym->parent) + sym = sym->parent; + } + + return sym->compound; +} + SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_functions) { symbol *sym,*parent_sym; @@ -2427,7 +2437,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_ * specified nesting level */ while (root->next!=NULL) { sym=root->next; - if (sym->compoundident) { case iLABEL: