epee: check some error return values

This commit is contained in:
moneromooo-monero 2017-12-27 00:14:43 +00:00
parent 4b156c003b
commit e4bbeff2f5
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 18 additions and 8 deletions

View File

@ -60,8 +60,7 @@ namespace epee
LOG_ERROR("Failed to load_from_binary on command " << command); LOG_ERROR("Failed to load_from_binary on command " << command);
return false; return false;
} }
result_struct.load(stg_ret); return result_struct.load(stg_ret);
return true;
} }
template<class t_arg, class t_transport> template<class t_arg, class t_transport>
@ -105,9 +104,7 @@ namespace epee
LOG_ERROR("Failed to load_from_binary on command " << command); LOG_ERROR("Failed to load_from_binary on command " << command);
return false; return false;
} }
result_struct.load(stg_ret); return result_struct.load(stg_ret);
return true;
} }
template<class t_result, class t_arg, class callback_t, class t_transport> template<class t_result, class t_arg, class callback_t, class t_transport>
@ -133,7 +130,12 @@ namespace epee
cb(LEVIN_ERROR_FORMAT, result_struct, context); cb(LEVIN_ERROR_FORMAT, result_struct, context);
return false; return false;
} }
result_struct.load(stg_ret); if (!result_struct.load(stg_ret))
{
LOG_ERROR("Failed to load result struct on command " << command);
cb(LEVIN_ERROR_FORMAT, result_struct, context);
return false;
}
cb(code, result_struct, context); cb(code, result_struct, context);
return true; return true;
}, inv_timeout); }, inv_timeout);
@ -176,7 +178,11 @@ namespace epee
boost::value_initialized<t_in_type> in_struct; boost::value_initialized<t_in_type> in_struct;
boost::value_initialized<t_out_type> out_struct; boost::value_initialized<t_out_type> out_struct;
static_cast<t_in_type&>(in_struct).load(strg); if (!static_cast<t_in_type&>(in_struct).load(strg))
{
LOG_ERROR("Failed to load in_struct in command " << command);
return -1;
}
int res = cb(command, static_cast<t_in_type&>(in_struct), static_cast<t_out_type&>(out_struct), context); int res = cb(command, static_cast<t_in_type&>(in_struct), static_cast<t_out_type&>(out_struct), context);
serialization::portable_storage strg_out; serialization::portable_storage strg_out;
static_cast<t_out_type&>(out_struct).store(strg_out); static_cast<t_out_type&>(out_struct).store(strg_out);
@ -200,7 +206,11 @@ namespace epee
return -1; return -1;
} }
boost::value_initialized<t_in_type> in_struct; boost::value_initialized<t_in_type> in_struct;
static_cast<t_in_type&>(in_struct).load(strg); if (!static_cast<t_in_type&>(in_struct).load(strg))
{
LOG_ERROR("Failed to load in_struct in notify " << command);
return -1;
}
return cb(command, in_struct, context); return cb(command, in_struct, context);
} }