Qt: Fix leaks VOIP Calls Dialog

There's still one small leak because RTP streams pass ownership
of an rtpstream_info_t to sequence analysis, which doesn't know
how to free it.
This commit is contained in:
John Thacker 2023-05-11 00:03:37 -04:00
parent aa52529225
commit f8f9112f9a
5 changed files with 24 additions and 10 deletions

View File

@ -193,6 +193,14 @@ static void sequence_analysis_item_free(gpointer data)
free_address(&seq_item->src_addr);
free_address(&seq_item->dst_addr);
if (seq_item->info_ptr) {
#if 0
/* XXX: If seq_item->info_type is GA_INFO_TYPE_RTP, then we need
* to free the data, but rtpstream_info_free_* is in libui and
* not exported. */
if (seq_item->info_type == GA_INFO_TYPE_RTP) {
rtpstream_info_free_data((rtpstream_info_t *)seq_item->info_ptr);
}
#endif
g_free(seq_item->info_ptr);
}
g_free(data);

View File

@ -34,6 +34,12 @@ extern "C" {
#define MAX_NUM_NODES 40
/** defines info types for graph analysis additional information */
typedef enum _ga_info_type {
GA_INFO_TYPE_NONE=0,
GA_INFO_TYPE_RTP
} ga_info_type;
/** defines an entry for the graph analysis */
typedef struct _seq_analysis_item {
guint32 frame_number;
@ -52,7 +58,7 @@ typedef struct _seq_analysis_item {
guint src_node; /**< this is used by graph_analysis.c to identify the node */
guint dst_node; /**< a node is an IP address that will be displayed in columns */
guint16 line_style; /**< the arrow line width in pixels*/
guint32 info_type; /**< type of info for item */
ga_info_type info_type; /**< type of info for item */
gpointer info_ptr; /**< ptr to info for item */
} seq_analysis_item_t;

View File

@ -327,7 +327,10 @@ void VoipCallsDialog::tapReset(void *tapinfo_ptr)
VoipCallsDialog *voip_calls_dialog = static_cast<VoipCallsDialog *>(tapinfo->tap_data);
// Create new callsinfos queue in tapinfo. Current callsinfos are
// in shown_callsinfos_.
// in shown_callsinfos_, so don't free the [shared] data stored in
// the queue, but do free the queue itself. (Do this before calling
// voip_calls_reset_all_taps(), as that frees the data in the queue.)
g_queue_free(voip_calls_dialog->tapinfo_.callsinfos);
voip_calls_dialog->tapinfo_.callsinfos = g_queue_new();
voip_calls_reset_all_taps(tapinfo);

View File

@ -280,7 +280,7 @@ voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
/* free the SIP_HASH */
if(NULL!=tapinfo->callsinfo_hashtable[SIP_HASH])
{
g_hash_table_remove_all (tapinfo->callsinfo_hashtable[SIP_HASH]);
g_hash_table_destroy(tapinfo->callsinfo_hashtable[SIP_HASH]);
tapinfo->callsinfo_hashtable[SIP_HASH] = NULL;
}
@ -289,12 +289,15 @@ voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
while(list)
{
strinfo = (rtpstream_info_t *)list->data;
rtpstream_info_free_data(strinfo);
rtpstream_info_free_all(strinfo);
list = g_list_next(list);
}
g_list_free(tapinfo->rtpstream_list);
tapinfo->rtpstream_list = NULL;
g_free(tapinfo->sdp_summary);
tapinfo->sdp_summary = NULL;
if (tapinfo->h245_labels) {
memset(tapinfo->h245_labels, 0, sizeof(h245_labels_t));
}

View File

@ -140,12 +140,6 @@ typedef struct _skinny_calls_info {
guint32 callId;
} skinny_calls_info_t;
/** defines info types for graph analysis additional information */
typedef enum _ga_info_type {
GA_INFO_TYPE_NONE=0,
GA_INFO_TYPE_RTP
} ga_info_type;
/** defines a voip call */
typedef struct _voip_calls_info {
voip_call_state call_state;