From 2288c6bb3f8ad1972315d98d8271ae9fbf391cde Mon Sep 17 00:00:00 2001 From: eteo Date: Sun, 23 Apr 2006 11:05:00 +0000 Subject: [PATCH] 2006-04-23 Eugene Teo PR 2149 * translate.cxx (mapvar::set): Test _stp_map_set_xx() for array overflows. --- ChangeLog | 6 ++++++ translate.cxx | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e75c78cc..3bea623f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-23 Eugene Teo + + PR 2149 + * translate.cxx (mapvar::set): Test _stp_map_set_xx() for + array overflows. + 2006-04-23 Eugene Teo * small_demos/ansi_colors.stp: Add an example of using octal diff --git a/translate.cxx b/translate.cxx index 83d6dd933..f3a5b23d2 100644 --- a/translate.cxx +++ b/translate.cxx @@ -581,14 +581,20 @@ struct mapvar string set (vector const & indices, tmpvar const & val) const { + string res = "{ int rc = "; + // impedance matching: empty strings -> NULL if (type() == pe_string) - return (call_prefix("set", indices) + res += (call_prefix("set", indices) + ", (" + val.qname() + "[0] ? " + val.qname() + " : NULL))"); else if (type() == pe_long) - return (call_prefix("set", indices) + ", " + val.qname() + ")"); + res += (call_prefix("set", indices) + ", " + val.qname() + ")"); else throw semantic_error("setting a value of an unsupported map type"); + + res += "; if (unlikely(rc)) c->last_error = \"Array overflow, check MAXMAPENTRIES\"; }"; + + return res; } string hist() const -- 2.43.5