diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-05-04 22:53:25 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2018-05-09 18:42:27 +0000 |
commit | e76ca2d3cb005d9276c953a14e63523a21cdb8dc (patch) | |
tree | 016770006dccdf37ffc0e8a47d8cc8751a4cbbc3 /ui | |
parent | 67ea8cb25fab11c4ac36393e4f184bee17bdf965 (diff) |
ui/tap-rtp-common: fix some memleaks
If a stream with the given parameters was already known, the addresses
and payload_type_name would be leaked. There are potential other leaks
for rtp_stream_info_t (also in Qt RtpAnalysisDialog::showPlayer), but
that requires a more careful analysis. Found by Clang Static Analyzer.
Change-Id: I2fb19464b4c0f89d597a7e6117d219111922b4f2
Reviewed-on: https://code.wireshark.org/review/27346
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/tap-rtp-common.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ui/tap-rtp-common.c b/ui/tap-rtp-common.c index b8d7c4e335..afbba37d8a 100644 --- a/ui/tap-rtp-common.c +++ b/ui/tap-rtp-common.c @@ -77,6 +77,7 @@ void rtpstream_reset(rtpstream_tapinfo_t *tapinfo) while (list) { g_free(list->data); + /* TODO free src_addr, dest_addr and payload_type_name? */ list = g_list_next(list); } g_list_free(tapinfo->strinfo_list); @@ -195,15 +196,16 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con struct _rtp_conversation_info *p_conv_data = NULL; - /* gather infos on the stream this packet is part of */ + /* gather infos on the stream this packet is part of. + * Addresses and strings are read-only and must be duplicated if copied. */ memset(&new_stream_info, 0, sizeof(rtp_stream_info_t)); - copy_address(&(new_stream_info.src_addr), &(pinfo->src)); + copy_address_shallow(&(new_stream_info.src_addr), &(pinfo->src)); new_stream_info.src_port = pinfo->srcport; - copy_address(&(new_stream_info.dest_addr), &(pinfo->dst)); + copy_address_shallow(&(new_stream_info.dest_addr), &(pinfo->dst)); new_stream_info.dest_port = pinfo->destport; new_stream_info.ssrc = rtpinfo->info_sync_src; new_stream_info.payload_type = rtpinfo->info_payload_type; - new_stream_info.payload_type_name = g_strdup(rtpinfo->info_payload_type_str); + new_stream_info.payload_type_name = (char *)rtpinfo->info_payload_type_str; if (tapinfo->mode == TAP_ANALYSE) { /* check whether we already have a stream with these parameters in the list */ @@ -235,6 +237,10 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con new_stream_info.setup_frame_number = 0xFFFFFFFF; stream_info = g_new(rtp_stream_info_t,1); + /* Deep clone of contents. */ + copy_address(&(new_stream_info.src_addr), &(new_stream_info.src_addr)); + copy_address(&(new_stream_info.dest_addr), &(new_stream_info.dest_addr)); + new_stream_info.payload_type_name = g_strdup(new_stream_info.payload_type_name); *stream_info = new_stream_info; /* memberwise copy of struct */ tapinfo->strinfo_list = g_list_prepend(tapinfo->strinfo_list, stream_info); } |