Skip to content

Commit 2e044c7

Browse files
authored
Merge pull request #310 from boostorg/feature/va-start
Restore removed va_start calls; add missing va_end as reported in #264.
2 parents 2805bc3 + d52537a commit 2e044c7

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

include/boost/serialization/extended_type_info_no_rtti.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,26 @@ class extended_type_info_no_rtti :
129129
}
130130
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
131131
// count up the arguments
132+
void * r = NULL;
132133
std::va_list ap;
134+
va_start(ap, count);
133135
switch(count){
134136
case 0:
135-
return factory<typename boost::remove_const< T >::type, 0>(ap);
137+
r = factory<typename boost::remove_const< T >::type, 0>(ap);
136138
case 1:
137-
return factory<typename boost::remove_const< T >::type, 1>(ap);
139+
r = factory<typename boost::remove_const< T >::type, 1>(ap);
138140
case 2:
139-
return factory<typename boost::remove_const< T >::type, 2>(ap);
141+
r = factory<typename boost::remove_const< T >::type, 2>(ap);
140142
case 3:
141-
return factory<typename boost::remove_const< T >::type, 3>(ap);
143+
r = factory<typename boost::remove_const< T >::type, 3>(ap);
142144
case 4:
143-
return factory<typename boost::remove_const< T >::type, 4>(ap);
145+
r = factory<typename boost::remove_const< T >::type, 4>(ap);
144146
default:
145147
BOOST_ASSERT(false); // too many arguments
146148
// throw exception here?
147-
return NULL;
148149
}
150+
va_end(ap);
151+
return r;
149152
}
150153
void destroy(void const * const p) const BOOST_OVERRIDE {
151154
boost::serialization::access::destroy(

include/boost/serialization/extended_type_info_typeid.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,26 @@ class extended_type_info_typeid :
112112
}
113113
void * construct(unsigned int count, ...) const BOOST_OVERRIDE {
114114
// count up the arguments
115+
void * r = NULL;
115116
std::va_list ap;
117+
va_start(ap, count);
116118
switch(count){
117119
case 0:
118-
return factory<typename boost::remove_const< T >::type, 0>(ap);
120+
r = factory<typename boost::remove_const< T >::type, 0>(ap);
119121
case 1:
120-
return factory<typename boost::remove_const< T >::type, 1>(ap);
122+
r = factory<typename boost::remove_const< T >::type, 1>(ap);
121123
case 2:
122-
return factory<typename boost::remove_const< T >::type, 2>(ap);
124+
r = factory<typename boost::remove_const< T >::type, 2>(ap);
123125
case 3:
124-
return factory<typename boost::remove_const< T >::type, 3>(ap);
126+
r = factory<typename boost::remove_const< T >::type, 3>(ap);
125127
case 4:
126-
return factory<typename boost::remove_const< T >::type, 4>(ap);
128+
r = factory<typename boost::remove_const< T >::type, 4>(ap);
127129
default:
128130
BOOST_ASSERT(false); // too many arguments
129131
// throw exception here?
130-
return NULL;
131132
}
133+
va_end(ap);
134+
return r;
132135
}
133136
void destroy(void const * const p) const BOOST_OVERRIDE {
134137
boost::serialization::access::destroy(

0 commit comments

Comments
 (0)