sipgo icon indicating copy to clipboard operation
sipgo copied to clipboard

DialogClientSession's OnResponse callback issue

Open yallxe opened this issue 6 months ago • 0 comments

I earlier already talked about this issue here: https://github.com/emiago/sipgo/issues/105#issuecomment-2265594564 But it would be better to open a new issue for it.

https://github.com/emiago/sipgo/blob/7fd2f42f16c9876277491e9cd018cb41a72ff5ed/dialog_client.go#L362-L368 In my opinion, s.InviteResponse should be updated before calling the OnResponse function. The reason to this is, if OnResponse function returns an error, the last invite response may be nil which could lead to panics if trying to use it.

Example: Let's say on first received response (let the status code be >=200, 100-199 responses were lost), OnResponse returned an error. Therefore the WaitAnswer() function returns an error, and InviteResponse is not set. If user doesn't manually check if s.InviteResponse for nil value, he might call Ack() function which will panic.

yallxe avatar Aug 06 '24 14:08 yallxe