# HG changeset patch # User Daniel Atallah # Date 1209762599 0 # Node ID 6b182ab4bc058a3290fa6f84f97cc15e8ad90ad8 # Parent dec78ddd46aadeb788ed54805da12efd83d9a36f Leak plug in parsing MSN currentmedia. diff -r dec78ddd46aa -r 6b182ab4bc05 libpurple/protocols/msn/state.c --- a/libpurple/protocols/msn/state.c Fri May 02 17:09:50 2008 +0000 +++ b/libpurple/protocols/msn/state.c Fri May 02 21:09:59 2008 +0000 @@ -87,7 +87,8 @@ 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 @@ * 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 && !strcmp(cmedia_array[2], "1")) { + parsed = TRUE; - if (strings < 4) - return FALSE; - if (strcmp(cmedia_array[2], "1")) - return FALSE; + g_free(media->title); + if (strings == 4) { + media->title = g_strdup(cmedia_array[3]); + } else { + media->title = g_strdup(cmedia_array[4]); + } - if (strings == 4) { - media->title = g_strdup(cmedia_array[3]); - } else { - media->title = g_strdup(cmedia_array[4]); + g_free(media->artist); + if (strings > 5) + media->artist = g_strdup(cmedia_array[5]); + else + media->artist = NULL; + + g_free(media->album); + if (strings > 6) + media->album = g_strdup(cmedia_array[6]); + else + media->album = NULL; + } - if (strings > 5) - media->artist = g_strdup(cmedia_array[5]); - else - media->artist = NULL; + g_strfreev(cmedia_array); - if (strings > 6) - media->album = g_strdup(cmedia_array[6]); - else - media->album = NULL; - - return TRUE; + return parsed; } /* get the CurrentMedia info from the XML string */