changeset 22837:7d4fcb142572

Fix some potential leakage in the craziness called purple_markup_html_to_xhtml().
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 07 May 2008 19:43:40 +0000
parents 56a38b60576e
children b4b7ba4d1a66
files libpurple/util.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Wed May 07 19:06:28 2008 +0000
+++ b/libpurple/util.c	Wed May 07 19:43:40 2008 +0000
@@ -1525,6 +1525,8 @@
 					while(*p && *p != '>') {
 						if(!g_ascii_strncasecmp(p, "src=", strlen("src="))) {
 							const char *q = p + strlen("src=");
+							if (src)
+								g_string_free(src, TRUE);
 							src = g_string_new("");
 							if(*q == '\'' || *q == '\"')
 								q++;
@@ -1535,6 +1537,8 @@
 							p = q;
 						} else if(!g_ascii_strncasecmp(p, "alt=", strlen("alt="))) {
 							const char *q = p + strlen("alt=");
+							if (alt)
+								g_string_free(alt, TRUE);
 							alt = g_string_new("");
 							if(*q == '\'' || *q == '\"')
 								q++;
@@ -1572,6 +1576,8 @@
 							if (url)
 								g_string_free(url, TRUE);
 							url = g_string_new("");
+							if (cdata)
+								g_string_free(cdata, TRUE);
 							cdata = g_string_new("");
 							if(*q == '\'' || *q == '\"')
 								q++;
@@ -4209,8 +4215,7 @@
 			/* not sure if this fallback is useful at all */
 			if (!node->data) node->data = g_strdup (s+5);
 		} else {
-			result = g_list_remove_link(result, node);
-			g_list_free_1 (node);
+			result = g_list_delete_link(result, node);
 		}
 		g_free (s);
 	}