Fix a memory leak in VariableServerThread_commands. Ref #333

This commit is contained in:
John M. Penn 2016-11-02 14:12:31 -05:00
parent 8ad462cd1c
commit 99c8b11709

View File

@ -98,6 +98,7 @@ int Trick::VariableServerThread::var_remove(std::string in_name) {
for ( ii = 0 ; ii < vars.size() ; ii++ ) { for ( ii = 0 ; ii < vars.size() ; ii++ ) {
std::string var_name = vars[ii]->ref->reference; std::string var_name = vars[ii]->ref->reference;
if ( ! var_name.compare(in_name) ) { if ( ! var_name.compare(in_name) ) {
delete vars[ii];
vars.erase(vars.begin() + ii) ; vars.erase(vars.begin() + ii) ;
break ; break ;
} }
@ -188,7 +189,10 @@ int Trick::VariableServerThread::var_exists(std::string in_name) {
} }
int Trick::VariableServerThread::var_clear() { int Trick::VariableServerThread::var_clear() {
vars.clear() ; while( !vars.empty() ) {
delete vars.back();
vars.pop_back();
}
return(0) ; return(0) ;
} }