[ndnSIM] m_delegation is empty while added delegation

Junxiao Shi shijunxiao at email.arizona.edu
Sun Oct 23 08:23:45 PDT 2016


Hi Sabet

#3803-6 <https://redmine.named-data.net/issues/3803#note-6> has decided
that Link without delegation is invalid. Therefore, it's correct for Link(const
Block&) constructor to throw an exception.
However, the snippet quoted below isn't implemented correctly. It attempts
to access m_delegations before calling wireDecode, but m_delegations is not
populated until wireDecode is executed. Thus, the exception will always be
thrown.
While moving the check after wireDecode call would solve the problem, the
proper place for this check is at the end of wireDecode, because some
programs may elect to default-construct a Link instance, and invoke
wireDecode with a block to decode ( Link link; link.wireDecode(block); ),
and an exception should be thrown in that situation as well.

Yours, Junxiao

On Thu, Oct 20, 2016 at 10:40 AM, Muhammad Hosain Abdollahi Sabet <
mhasabet at gmail.com> wrote:
>
> Link::Link(const Block& block)
>> {
>>   if(m_delegations.empty()){
>>       BOOST_THROW_EXCEPTION(Error("Link object has no delegationName!"));
>>   }
>>   wireDecode(block);
>> }
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20161023/c2627e74/attachment.html>


More information about the ndnSIM mailing list