freeswitch
freeswitch copied to clipboard
[Core] Fix a memory leak when processing MSRP packets
The purpose of this PR is to fix a memory leak. Consider this scenario:
- msrp_parse_buffer is invoked and it fails to process to parse the message (see line 894) and it leaves the message in the MSRP_ST_WAIT_HEADER state
- On line 1258 when the message state is analyzed, processing will fall through to the default error case logging ("Parse initial message error!") and then will jump to "end" without destroying the msrg_msg buffer. This will cause a memory leak.
The problem is that in that error check, the msg state is in the MSRP_ST_WAIT_HEADER state which is not explicitly checked and the function exits to "end" without de-allocating the msrp_msg buffer.