From a6aae0cc4a2af798dd9808075cab92ac8139a36a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 17 Sep 2013 14:06:22 +0200 Subject: Fix polymorphic section index overrun --- odb/relational/source.cxx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'odb/relational/source.cxx') diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx index 7a0627d..366120c 100644 --- a/odb/relational/source.cxx +++ b/odb/relational/source.cxx @@ -552,19 +552,22 @@ traverse_object (type& c) (poly ? user_sections::count_optimistic : 0)) != 0); if (sections) { + string const& fn (flat_name (type)); + + size_t n (uss.count (user_sections::count_total | + user_sections::count_all | + user_sections::count_special_version)); + map m; for (user_sections::iterator i (uss.begin ()); i != uss.end (); ++i) m[i->index] = &*i; os << "static const "<< traits << "::" << (abst ? "abstract_" : "") << "info_type::section_functions" << endl - << "section_table_for_" << flat_name (type) << "[] =" + << "section_functions_for_" << fn << "[] =" << "{"; - for (size_t i (0), n (uss.count (user_sections::count_total | - user_sections::count_all | - user_sections::count_special_version)); - i != n; ++i) + for (size_t i (0); i != n; ++i) { os << (i != 0 ? "," : "") << "{"; @@ -605,6 +608,14 @@ traverse_object (type& c) } os << "};"; + + os << "static const "<< traits << "::" << (abst ? "abstract_" : "") << + "info_type::section_list" << endl + << "section_list_for_" << fn << " =" + << "{" + << n << "UL," << endl + << "section_functions_for_" << fn + << "};"; } // @@ -623,7 +634,7 @@ traverse_object (type& c) // Sections. // if (sections) - os << "section_table_for_" << flat_name (type); + os << "§ion_list_for_" << flat_name (type); else os << "0"; @@ -3175,8 +3186,8 @@ traverse_object (type& c) // version without updating anything. // if (i->optimistic ()) - os << "if (su != 0 && su != info.sections[" << i->index << - "UL].update)" << endl; + os << "if (su != 0 && su != info.sections->functions[" << + i->index << "UL].update)" << endl; else os << "if (su != 0)" << endl; } -- cgit v1.1