Fix uninitialized memory accesses.

This commit is contained in:
steve 2002-05-07 04:15:43 +00:00
parent e70e04d6e8
commit 68f1316eba
3 changed files with 20 additions and 8 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: arith.cc,v 1.22 2002/01/03 04:19:02 steve Exp $"
#ident "$Id: arith.cc,v 1.23 2002/05/07 04:15:43 steve Exp $"
#endif
# include "arith.h"
@ -58,8 +58,8 @@ void vvp_arith_::output_val_(vvp_ipoint_t base, bool push, unsigned long sum)
vvp_wide_arith_::vvp_wide_arith_(unsigned wid)
: vvp_arith_(wid)
{
unsigned np = (wid + pagesize - 1)/pagesize;
sum_ = (unsigned long *)malloc(np*sizeof(unsigned long));
pagecount_ = (wid + pagesize - 1)/pagesize;
sum_ = (unsigned long *)calloc(pagecount_, sizeof(unsigned long));
assert(sum_);
}
@ -308,7 +308,8 @@ void vvp_arith_sum::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
if (pbit >= pagesize) {
pbit = 0;
page += 1;
sum_[page] = carry;
if (page < pagecount_)
sum_[page] = carry;
carry = 0;
}
}
@ -370,7 +371,8 @@ void vvp_arith_sub::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
if (pbit >= pagesize) {
pbit = 0;
page += 1;
sum_[page] = carry;
if (page < pagecount_)
sum_[page] = carry;
carry = 0;
}
}
@ -549,6 +551,9 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
/*
* $Log: arith.cc,v $
* Revision 1.23 2002/05/07 04:15:43 steve
* Fix uninitialized memory accesses.
*
* Revision 1.22 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: arith.h,v 1.12 2002/01/03 04:19:02 steve Exp $"
#ident "$Id: arith.h,v 1.13 2002/05/07 04:15:43 steve Exp $"
#endif
# include "functor.h"
@ -47,6 +47,7 @@ class vvp_wide_arith_ : public vvp_arith_ {
protected:
static const unsigned pagesize = 8*sizeof(unsigned long);
unsigned pagecount_;
unsigned long *sum_;
void output_val_(vvp_ipoint_t base, bool push);
@ -134,6 +135,9 @@ class vvp_shiftr : public vvp_arith_ {
/*
* $Log: arith.h,v $
* Revision 1.13 2002/05/07 04:15:43 steve
* Fix uninitialized memory accesses.
*
* Revision 1.12 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.cc,v 1.125 2002/04/21 22:29:49 steve Exp $"
#ident "$Id: compile.cc,v 1.126 2002/05/07 04:15:43 steve Exp $"
#endif
# include "arith.h"
@ -355,7 +355,7 @@ bool vpi_handle_resolv_list_s::resolve(bool mes)
if (!val.ptr) {
// check for thread vector T<base,wid>
unsigned base, wid;
unsigned n;
unsigned n = 0;
char ss[32];
if (2 <= sscanf(label, "T<%u,%u>%n", &base, &wid, &n)
&& n == strlen(label)) {
@ -1410,6 +1410,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
/*
* $Log: compile.cc,v $
* Revision 1.126 2002/05/07 04:15:43 steve
* Fix uninitialized memory accesses.
*
* Revision 1.125 2002/04/21 22:29:49 steve
* Add the assign/d instruction for computed delays.
*