Closed sonelu closed 3 years ago
Hi @sonelu
The conditional statement you mentioned is checking whether the packet buffer pointer is created successfully or not so that p_buf
can be used for p_pack
etbuf
Hi @ROBOTIS-Will,
Sorry, but I really don't see the point of that.
The following code will work fine and would practically brick the Slave instance:
slave.setPacketBuffer(nullptr, 10);
Any subsequent calls to fix the buffer after that will fail because of that check:
buff_new = new unit8_t[20];
slave.setPacketBuffer(buff_new, 20);
Am I missing something?
Hi @sonelu , I don't think anyone would intentionally pass the null pointer to the setPacketBuffer function, but in order to achieve safer code, you may append validation process for the parameters. @OpusK Any thoughts on this issue?
@sonelu , @ROBOTIS-Will
Oh, sorry guys. It is just a typo... p_buf is correct.
@OpusK Thank you for confirming this issue.
This issue will be closed with the fix #51 . Please feel free to reopen when necessary.
In slave.cpp I think there is typo in the
setPacketBuffer
:shouldn't this be instead:
The check should be against
p_buf
argument and not againstp_packet_buf_
attribute?