ref: 60f62db06595ad07503f3a587607d466c0d460a0
parent: 06fffa554b4c6d04b37f148160c81c7e840c7601
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 9 13:07:11 EDT 2014
Fix bug in Symbol allocation in cc2 We were allocating using only the number of elements, and not the size of each element, so at the end we were writing after the end of the array.
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -84,8 +84,8 @@
if (i >= NR_INT_IDENT)
error(EINTNUM);
if (i > nr) {
- nr = i + 5;
- localtbl = xrealloc(localtbl, nr);
+ nr = i + 50;
+ localtbl = xrealloc(localtbl, nr * sizeof(Symbol));
}
return &localtbl[i];
}
@@ -99,8 +99,8 @@
if (i >= NR_EXT_IDENT)
error(EEXTNUM);
if (i >= nr) {
- nr = i + 5;
- globaltbl = xrealloc(globaltbl, nr);
+ nr = i + 50;
+ globaltbl = xrealloc(globaltbl, nr * sizeof(Symbol));
}
return &globaltbl[i];
}