From e95328a5167cc653ecbb3aa7dca99f34f085edce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 26 Aug 2016 12:05:52 +0200 Subject: [PATCH] Bug #4745: Fix segfault for malformed template attributes --- include/Template.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/Template.h b/include/Template.h index ec03238c99..8ad0d9051e 100644 --- a/include/Template.h +++ b/include/Template.h @@ -512,11 +512,11 @@ private: multimap::const_iterator i; - int j; + int j = 0; index = attributes.equal_range(name); - for (i = index.first, j = 0 ; i != index.second ; i++, j++) + for (i = index.first; i != index.second ; i++) { const T * vatt = dynamic_cast(i->second); @@ -526,6 +526,7 @@ private: } values.push_back(vatt); + j++; } return j; @@ -540,11 +541,11 @@ private: multimap::iterator i; - int j; + int j = 0; index = attributes.equal_range(name); - for (i = index.first, j = 0 ; i != index.second ; i++, j++) + for (i = index.first; i != index.second ; i++) { T * vatt = dynamic_cast(i->second); @@ -554,6 +555,7 @@ private: } values.push_back(vatt); + j++; } return j;