[gstreamer-bugs] [Bug 407793] New: memory leaks of sdpmessage.c
GStreamer (bugzilla.gnome.org)
bugzilla-daemon at bugzilla.gnome.org
Wed Feb 14 01:06:17 PST 2007
Do not reply to this via email (we are currently unable to handle email
responses and they get discarded). You can add comments to this bug at
http://bugzilla.gnome.org/show_bug.cgi?id=407793
GStreamer | gst-plugins-good | Ver: 0.10.5
Summary: memory leaks of sdpmessage.c
Product: GStreamer
Version: 0.10.5
Platform: Other
OS/Version: Linux
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: gst-plugins-good
AssignedTo: gstreamer-bugs at lists.sourceforge.net
ReportedBy: jp_liu at astrocom.cn
QAContact: gstreamer-bugs at lists.sourceforge.net
GNOME version: Unspecified
GNOME milestone: Unspecified
There are some memory leaks of sdpmessage in sdpmessage.c when
sdp_message_clean.
The following patch fix it.
--- sdpmessage.c.orig 2006-09-21 00:06:28.000000000 +0800
+++ sdpmessage.c 2007-02-14 09:59:02.858530144 +0800
@@ -48,7 +48,7 @@
/* FIXME, is currently allocated on the stack */
#define MAX_LINE_LEN 1024 * 16
-#define FREE_STRING(field) g_free ((field)); (field) = NULL;
+#define FREE_STRING(field) if(field) { g_free ((field)); (field) = NULL;
}
#define FREE_ARRAY(field) \
G_STMT_START { \
if (field) \
@@ -147,16 +147,77 @@
RTSPResult
sdp_message_clean (SDPMessage * msg)
{
+ unsigned int i;
+
g_return_val_if_fail (msg != NULL, RTSP_EINVAL);
+ for(i=0; i<msg->emails->len; i++)
+ {
+ g_free (g_array_index(msg->emails, gchar *, i));
+ }
FREE_ARRAY (msg->emails);
+
+ for(i=0; i<msg->phones->len; i++)
+ {
+ g_free (g_array_index(msg->phones, gchar *, i));
+ }
FREE_ARRAY (msg->phones);
+
+ for(i=0; i<msg->bandwidths->len; i++)
+ {
+ SDPBandwidth* bw = &g_array_index(msg->bandwidths, SDPBandwidth, i);
+ FREE_STRING (bw->bwtype);
+ }
FREE_ARRAY (msg->bandwidths);
+
+ for(i=0; i<msg->times->len; i++)
+ {
+ SDPTime* time = &g_array_index(msg->times, SDPTime, i);
+ FREE_STRING (time->start);
+ FREE_STRING (time->stop);
+ }
FREE_ARRAY (msg->times);
+
+ for(i=0; i<msg->zones->len; i++)
+ {
+ SDPZone* zone = &g_array_index(msg->zones, SDPZone, i);
+ FREE_STRING (zone->time);
+ FREE_STRING (zone->typed_time);
+ }
FREE_ARRAY (msg->zones);
+
+ for(i=0; i<msg->attributes->len; i++)
+ {
+ SDPAttribute* attr = &g_array_index(msg->attributes, SDPAttribute, i);
+ FREE_STRING (attr->key);
+ FREE_STRING (attr->value);
+ }
FREE_ARRAY (msg->attributes);
+
+ for(i=0; i<msg->medias->len; i++)
+ {
+ SDPMedia* media = &g_array_index(msg->medias, SDPMedia, i);
+ sdp_media_clean(media);
+ }
FREE_ARRAY (msg->medias);
+ //added FREE_STRING by jp.liu
+ FREE_STRING (msg->version);
+ FREE_STRING (msg->origin.username);
+ FREE_STRING (msg->origin.sess_id);
+ FREE_STRING (msg->origin.sess_version);
+ FREE_STRING (msg->origin.nettype);
+ FREE_STRING (msg->origin.addrtype);
+ FREE_STRING (msg->origin.addr);
+ FREE_STRING (msg->session_name);
+ FREE_STRING (msg->information);
+ FREE_STRING (msg->uri);
+ FREE_STRING (msg->connection.nettype);
+ FREE_STRING (msg->connection.addrtype);
+ FREE_STRING (msg->connection.address);
+ FREE_STRING (msg->key.type);
+ FREE_STRING (msg->key.data);
+
return RTSP_OK;
}
@@ -187,6 +248,65 @@
return sdp_media_init (newmedia);
}
+//added these 2 functions by jp.liu
+
+RTSPResult
+sdp_media_clean(SDPMedia *media)
+{
+ unsigned int i;
+
+ FREE_STRING (media->media);
+ FREE_STRING (media->proto);
+ FREE_STRING (media->information);
+ FREE_STRING (media->key.data);
+ FREE_STRING (media->key.type);
+
+ for(i=0; i<media->fmts->len; i++)
+ {
+ char* fmt = g_array_index(media->fmts, gchar *, i);
+ FREE_STRING (fmt);
+ }
+ FREE_ARRAY (media->fmts);
+
+ for(i=0; i<media->connections->len; i++)
+ {
+ SDPConnection* conn = &g_array_index(media->connections,
SDPConnection, i);
+ FREE_STRING (conn->nettype);
+ FREE_STRING (conn->addrtype);
+ FREE_STRING (conn->address);
+ }
+ FREE_ARRAY (media->connections);
+
+ for(i=0; i<media->bandwidths->len; i++)
+ {
+ SDPBandwidth* bw = &g_array_index(media->bandwidths, SDPBandwidth, i);
+ FREE_STRING (bw->bwtype);
+ }
+ FREE_ARRAY (media->bandwidths);
+
+ for(i=0; i<media->attributes->len; i++)
+ {
+ SDPAttribute* attr = &g_array_index(media->attributes, SDPAttribute,
i);
+ FREE_STRING (attr->key);
+ FREE_STRING (attr->value);
+ }
+ FREE_ARRAY (media->attributes);
+
+ return RTSP_OK;
+}
+
+RTSPResult
+sdp_media_free(SDPMedia *media)
+{
+ g_return_val_if_fail (media != NULL, RTSP_EINVAL);
+
+ sdp_media_clean(media);
+
+ g_free(media);
+
+ return RTSP_OK;
+}
+
RTSPResult
sdp_media_init (SDPMedia * media)
{
--
Configure bugmail: http://bugzilla.gnome.org/userprefs.cgi?tab=email
More information about the Gstreamer-bugs
mailing list