Skip to content

Commit 9a9f4e7

Browse files
francisco-miguel-almeidameyerj
authored andcommitted
Merge pull request #296 from achim-k/master into toolchain-2.9.1
marsh: Fix memory leak in TinyDemarshaller.
2 parents b2d0ec6 + f550059 commit 9a9f4e7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

rtt/marsh/TinyDemarshaller.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ namespace RTT
9696
if ( type == "boolean" )
9797
{
9898
if ( value_string == "1" || value_string == "true")
99-
bag_stack.top().first->add
99+
bag_stack.top().first->ownProperty
100100
( new Property<bool>( name, description, true ) );
101101
else if ( value_string == "0" || value_string == "false")
102-
bag_stack.top().first->add
102+
bag_stack.top().first->ownProperty
103103
( new Property<bool>( name, description, false ) );
104104
else {
105105
log(Error)<< "Wrong value for property '"+type+"'." \
@@ -114,7 +114,7 @@ namespace RTT
114114
return false;
115115
}
116116
else
117-
bag_stack.top().first->add
117+
bag_stack.top().first->ownProperty
118118
( new Property<char>( name, description, value_string.empty() ? '\0' : value_string[0] ) );
119119
}
120120
else if ( type == "uchar" || type == "octet" ) {
@@ -124,7 +124,7 @@ namespace RTT
124124
return false;
125125
}
126126
else
127-
bag_stack.top().first->add
127+
bag_stack.top().first->ownProperty
128128
( new Property<unsigned char>( name, description, value_string.empty() ? '\0' : value_string[0] ) );
129129
}
130130
else if ( type == "long" || type == "short")
@@ -135,7 +135,7 @@ namespace RTT
135135
}
136136
int v;
137137
if ( sscanf(value_string.c_str(), "%d", &v) == 1)
138-
bag_stack.top().first->add( new Property<int>( name, description, v ) );
138+
bag_stack.top().first->ownProperty( new Property<int>( name, description, v ) );
139139
else {
140140
log(Error) << "Wrong value for property '"+type+"'." \
141141
" Value should contain an integer value, got '"+ value_string +"'." << endlog();
@@ -150,7 +150,7 @@ namespace RTT
150150
}
151151
unsigned int v;
152152
if ( sscanf(value_string.c_str(), "%u", &v) == 1)
153-
bag_stack.top().first->add( new Property<unsigned int>( name, description, v ) );
153+
bag_stack.top().first->ownProperty( new Property<unsigned int>( name, description, v ) );
154154
else {
155155
log(Error) << "Wrong value for property '"+type+"'." \
156156
" Value should contain an integer value, got '"+ value_string +"'." << endlog();
@@ -161,7 +161,7 @@ namespace RTT
161161
{
162162
long long v;
163163
if ( sscanf(value_string.c_str(), "%lld", &v) == 1)
164-
bag_stack.top().first->add( new Property<long long>( name, description, v ) );
164+
bag_stack.top().first->ownProperty( new Property<long long>( name, description, v ) );
165165
else {
166166
log(Error) << "Wrong value for property '"+type+"'." \
167167
" Value should contain an integer value, got '"+ value_string +"'." << endlog();
@@ -172,7 +172,7 @@ namespace RTT
172172
{
173173
unsigned long long v;
174174
if ( sscanf(value_string.c_str(), "%llu", &v) == 1)
175-
bag_stack.top().first->add( new Property<unsigned long long>( name, description, v ) );
175+
bag_stack.top().first->ownProperty( new Property<unsigned long long>( name, description, v ) );
176176
else {
177177
log(Error) << "Wrong value for property '"+type+"'." \
178178
" Value should contain an integer value, got '"+ value_string +"'." << endlog();
@@ -183,7 +183,7 @@ namespace RTT
183183
{
184184
double v;
185185
if ( sscanf(value_string.c_str(), "%lf", &v) == 1 )
186-
bag_stack.top().first->add
186+
bag_stack.top().first->ownProperty
187187
( new Property<double>( name, description, v ) );
188188
else {
189189
log(Error) << "Wrong value for property '"+type+"'." \
@@ -195,7 +195,7 @@ namespace RTT
195195
{
196196
float v;
197197
if ( sscanf(value_string.c_str(), "%f", &v) == 1 )
198-
bag_stack.top().first->add
198+
bag_stack.top().first->ownProperty
199199
( new Property<float>( name, description, v ) );
200200
else {
201201
log(Error) << "Wrong value for property '"+type+"'." \
@@ -204,7 +204,7 @@ namespace RTT
204204
}
205205
}
206206
else if ( type == "string")
207-
bag_stack.top().first->add
207+
bag_stack.top().first->ownProperty
208208
( new Property<std::string>( name, description, value_string ) );
209209
else{
210210
log(Error)<<"Unknown type \""<<type<< "\" for for tag simple"<<endlog();
@@ -221,7 +221,7 @@ namespace RTT
221221
{
222222
Property<PropertyBag>* prop = bag_stack.top().second;
223223
bag_stack.pop();
224-
bag_stack.top().first->add( prop );
224+
bag_stack.top().first->ownProperty( prop );
225225
//( new Property<PropertyBag>( pn, description, *pb ) );
226226
//delete pb;
227227
tag_stack.pop();
@@ -431,12 +431,10 @@ namespace RTT
431431
detail::Tiny2CPFHandler proc( v );
432432

433433
if ( proc.populateBag( propHandle.Node() ) == false) {
434-
deleteProperties( v );
435434
return false;
436435
}
437436
return true;
438437
}
439438

440439
}
441440
}
442-

0 commit comments

Comments
 (0)