Skip to content

Commit

Permalink
fix bug, the trim() function does not modify its parameter directly
Browse files Browse the repository at this point in the history
  • Loading branch information
vonhenry committed Apr 11, 2019
1 parent 6a45d96 commit ea0f57b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions plugins/ibc_plugin/ibc_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,23 +950,22 @@ namespace eosio { namespace ibc {

memo_info_type info;

string memo = memo_str;
trim( memo );
string memo = trim( memo_str );

// --- get receiver ---
auto pos = memo.find("@");
if ( pos == std::string::npos ){
elog("memo format error, didn't find charactor \'@\' in memo");
return optional<memo_info_type>();
}

string receiver_str = memo.substr( 0, pos );
trim( receiver_str );
receiver_str = trim( receiver_str );
info.receiver = name( receiver_str );

// --- trim ---
memo = memo.substr( pos + 1 );
trim( memo );
memo = trim( memo );

// --- get chain name and notes ---
pos = memo.find(" ");
Expand All @@ -976,7 +975,7 @@ namespace eosio { namespace ibc {
} else {
info.chain = name( memo.substr(0,pos) );
info.notes = memo.substr( pos + 1 );
trim( info.notes );
info.notes = trim( info.notes );
}

if ( info.receiver == name() ){
Expand All @@ -988,7 +987,7 @@ namespace eosio { namespace ibc {
elog("memo format error, chain not provided in memo");
return optional<memo_info_type>();
}

return info;
}

Expand Down

0 comments on commit ea0f57b

Please sign in to comment.