orcprogram-c: avoid running out of bounds of varnames
authorLuis de Bethencourt <luisbg@osg.samsung.com>
Mon, 14 Dec 2015 13:46:52 +0000 (13:46 +0000)
committerLuis de Bethencourt <luisbg@osg.samsung.com>
Mon, 14 Dec 2015 13:56:31 +0000 (13:56 +0000)
These two for loops use varnames[i], since varname has 48 items avoid
running out of bounds by running the for loop up to that limit.

CID 1147004

orc/orclimits.h
orc/orcprogram-c.c

index 928b00c..18f1d9e 100644 (file)
@@ -15,6 +15,7 @@ ORC_BEGIN_DECLS
 #define ORC_N_CONSTANTS 20
 #define ORC_N_LABELS 40
 #define ORC_N_COMPILER_VARIABLES (ORC_N_VARIABLES+32)
+#define ORC_N_VARNAMES 48
 
 #define ORC_GP_REG_BASE 32
 #define ORC_VEC_REG_BASE 64
index bff075a..43cfaed 100644 (file)
@@ -291,7 +291,7 @@ orc_compiler_c_assemble (OrcCompiler *compiler)
     ORC_ASM_CODE(compiler,"  for (j = 0; j < m; j++) {\n");
     prefix = 2;
 
-    for(i=0;i<ORC_N_COMPILER_VARIABLES;i++){
+    for(i=0;i<ORC_N_VARNAMES;i++){
       OrcVariable *var = compiler->vars + i;
       if (var->name == NULL) continue;
       switch (var->vartype) {
@@ -417,7 +417,7 @@ orc_compiler_c_assemble (OrcCompiler *compiler)
     ORC_ASM_CODE(compiler,"  }\n");
   }
 
-  for(i=0;i<ORC_N_COMPILER_VARIABLES;i++){
+  for(i=0;i<ORC_N_VARNAMES;i++){
     char varname[40];
     OrcVariable *var = compiler->vars + i;
     if (var->name == NULL) continue;