pidgin: 30ffdc24: Leak plug in parsing MSN currentmedia.
datallah at pidgin.im
datallah at pidgin.im
Fri May 2 18:05:42 EDT 2008
-----------------------------------------------------------------
Revision: 30ffdc24c362a88ea84a371324420ea3366c9677
Ancestor: 6b65012f4602a07c87d1e6f6ff080f95f13b18e0
Author: datallah at pidgin.im
Date: 2008-05-02T21:09:59
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/30ffdc24c362a88ea84a371324420ea3366c9677
Modified files:
libpurple/protocols/msn/state.c
ChangeLog:
Leak plug in parsing MSN currentmedia.
-------------- next part --------------
============================================================
--- libpurple/protocols/msn/state.c 46a8f9e65c37ac58ce781be735951285526d5898
+++ libpurple/protocols/msn/state.c 54706d075bbd006759acb584ca5c381256c9bea2
@@ -87,7 +87,8 @@ msn_parse_currentmedia(const char *cmedi
msn_parse_currentmedia(const char *cmedia, CurrentMedia *media)
{
char **cmedia_array;
- int strings;
+ int strings = 0;
+ gboolean parsed = FALSE;
if ((cmedia == NULL) || (*cmedia == '\0')) {
purple_debug_info("msn", "No currentmedia string\n");
@@ -108,31 +109,39 @@ msn_parse_currentmedia(const char *cmedi
* 6: Album
* 7: ?
*/
- strings = 0;
+#if GLIB_CHECK_VERSION(2,6,0)
+ strings = g_strv_length(cmedia_array);
+#else
while (cmedia_array[++strings] != NULL);
+#endif
- if (strings < 4)
- return FALSE;
- if (strcmp(cmedia_array[2], "1"))
- return FALSE;
+ if (strings >= 4 && !strcmp(cmedia_array[2], "1")) {
+ parsed = TRUE;
- if (strings == 4) {
- media->title = g_strdup(cmedia_array[3]);
- } else {
- media->title = g_strdup(cmedia_array[4]);
- }
+ g_free(media->title);
+ if (strings == 4) {
+ media->title = g_strdup(cmedia_array[3]);
+ } else {
+ media->title = g_strdup(cmedia_array[4]);
+ }
- if (strings > 5)
- media->artist = g_strdup(cmedia_array[5]);
- else
- media->artist = NULL;
+ g_free(media->artist);
+ if (strings > 5)
+ media->artist = g_strdup(cmedia_array[5]);
+ else
+ media->artist = NULL;
- if (strings > 6)
- media->album = g_strdup(cmedia_array[6]);
- else
- media->album = NULL;
+ g_free(media->album);
+ if (strings > 6)
+ media->album = g_strdup(cmedia_array[6]);
+ else
+ media->album = NULL;
- return TRUE;
+ }
+
+ g_strfreev(cmedia_array);
+
+ return parsed;
}
/* get the CurrentMedia info from the XML string */
More information about the Commits
mailing list