summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--translate.cxx25
2 files changed, 14 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f6e56d7..e233621c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-11-06 Martin Hunt <hunt@redhat.com>
+
+ * translate.cxx (var::init): Check for errors when
+ allocating arrays of stats, as well as other arrays.
+
2006-11-06 David Smith <dsmith@redhat.com>
Added "limit EXP" support to foreach statements.
diff --git a/translate.cxx b/translate.cxx
index 14d58ef2..a7406387 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -623,41 +623,34 @@ struct mapvar
string mtype = is_parallel() ? "pmap" : "map";
string prefix = qname() + " = _stp_" + mtype + "_new_" + keysym() + " (MAXMAPENTRIES" ;
+ // Check for errors during allocation.
+ string suffix = "if (" + qname () + " == NULL) rc = -ENOMEM;";
+
if (type() == pe_stats)
{
switch (sdecl().type)
{
case statistic_decl::none:
- return (prefix
- + ", HIST_NONE);");
+ prefix = prefix + ", HIST_NONE";
break;
case statistic_decl::linear:
// FIXME: check for "reasonable" values in linear stats
- return (prefix
- + ", HIST_LINEAR"
- + ", " + stringify(sdecl().linear_low)
- + ", " + stringify(sdecl().linear_high)
- + ", " + stringify(sdecl().linear_step)
- + ");");
+ prefix = prefix + ", HIST_LINEAR"
+ + ", " + stringify(sdecl().linear_low)
+ + ", " + stringify(sdecl().linear_high)
+ + ", " + stringify(sdecl().linear_step);
break;
case statistic_decl::logarithmic:
if (sdecl().logarithmic_buckets > 64)
throw semantic_error("cannot support > 64 logarithmic buckets");
- return (prefix
- + ", HIST_LOG"
- + ", " + stringify(sdecl().logarithmic_buckets)
- + ");");
+ prefix = prefix + ", HIST_LOG" + ", " + stringify(sdecl().logarithmic_buckets);
break;
}
}
prefix = prefix + "); ";
-
- // Check for errors during allocation.
- string suffix = "if (" + qname () + " == NULL) rc = -ENOMEM;";
-
return (prefix + suffix);
}