summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-20 21:28:02 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-20 21:28:02 +0000
commit9a975ad512c9f5632738ebc5fec473aff2b08087 (patch)
tree14ca1c6f8304fffb9a0f6733bbd9254530e7367b /common
parent73e0b1b5e832010192ec6d57e2afa36de2c96299 (diff)
Fix memory leaks in XML parser for SDP
Diffstat (limited to 'common')
-rw-r--r--common/sdp-glib.c2
-rw-r--r--common/sdp-xml.c18
2 files changed, 13 insertions, 7 deletions
diff --git a/common/sdp-glib.c b/common/sdp-glib.c
index 37c8580f..a24464ce 100644
--- a/common/sdp-glib.c
+++ b/common/sdp-glib.c
@@ -230,6 +230,8 @@ sdp_record_t *sdp_xml_parse_record(const char *data, int size)
return NULL;
}
+ g_markup_parse_context_free(ctx);
+
free(ctx_data);
return record;
diff --git a/common/sdp-xml.c b/common/sdp-xml.c
index 87200908..abebc652 100644
--- a/common/sdp-xml.c
+++ b/common/sdp-xml.c
@@ -676,6 +676,8 @@ static sdp_data_t *sdp_xml_parse_text_with_size(const char *data, char encoding,
debug("Unit size %d length %d: -->%s<--\n", ret->unitSize, length, text);
+ free(text);
+
return ret;
}
#endif
@@ -696,6 +698,8 @@ sdp_data_t *sdp_xml_parse_text(const char *data, char encoding)
debug("Unit size %d length %d: -->%s<--\n", ret->unitSize, length, text);
+ free(text);
+
return ret;
}
@@ -711,18 +715,16 @@ struct sdp_xml_data *sdp_xml_data_alloc()
struct sdp_xml_data *elem;
elem = malloc(sizeof(struct sdp_xml_data));
+ if (!elem)
+ return NULL;
+
+ memset(elem, 0, sizeof(struct sdp_xml_data));
/* Null terminate the text */
elem->size = DEFAULT_XML_DATA_SIZE;
elem->text = malloc(DEFAULT_XML_DATA_SIZE);
elem->text[0] = '\0';
- elem->next = 0;
- elem->data = 0;
-
- elem->type = 0;
- elem->name = 0;
-
return elem;
}
@@ -734,7 +736,9 @@ void sdp_xml_data_free(struct sdp_xml_data *elem)
if (elem->name)
free(elem->name);
- free(elem->text);
+ if (elem->text)
+
+ free(elem->text);
free(elem);
}