rhythmbox r5965 - in trunk: . plugins/audioscrobbler



Author: jmatthew
Date: Thu Oct  2 22:45:37 2008
New Revision: 5965
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5965&view=rev

Log:
2008-10-03  Jonathan Matthew  <jonathan d14n org>

	* plugins/audioscrobbler/rb-lastfm-source.c:
	(handle_handshake_response), (handle_station_response):
	Don't crash if the response data isn't in the format we expect to get
	from last.fm.  Fixes #554695.


Modified:
   trunk/ChangeLog
   trunk/plugins/audioscrobbler/rb-lastfm-source.c

Modified: trunk/plugins/audioscrobbler/rb-lastfm-source.c
==============================================================================
--- trunk/plugins/audioscrobbler/rb-lastfm-source.c	(original)
+++ trunk/plugins/audioscrobbler/rb-lastfm-source.c	Thu Oct  2 22:45:37 2008
@@ -1735,7 +1735,9 @@
 	pieces = g_strsplit (body, "\n", 0);
 	for (i = 0; pieces[i] != NULL; i++) {
 		gchar **values = g_strsplit (pieces[i], "=", 2);
-		if (strcmp (values[0], "session") == 0) {
+		if (values[0] == NULL) {
+			rb_debug ("unexpected response content: %s", pieces[i]);
+		} else if (strcmp (values[0], "session") == 0) {
 			if (strcmp (values[1], "FAILED") == 0) {
 				source->priv->state = LOGIN_FAILED;
 				rb_debug ("login failed");
@@ -1770,6 +1772,10 @@
 
 	g_strfreev (pieces);
 
+	if (source->priv->state != CONNECTED) {
+		return;
+	}
+
 	/* create default stations */
 	username = eel_gconf_get_string (CONF_AUDIOSCROBBLER_USERNAME);
 	if (username != NULL) {
@@ -1888,7 +1894,9 @@
 	for (i = 0; pieces[i] != NULL; i++) {
 		gchar **values = g_strsplit (pieces[i], "=", 2);
 
-		if (strcmp (values[0], "response") == 0) {
+		if (values[0] == NULL) {
+			rb_debug ("unexpected response content: %s", pieces[i]);
+		} else if (strcmp (values[0], "response") == 0) {
 			if (source->priv->current_station != NULL) {
 				rhythmdb_entry_unref (source->priv->current_station);
 				source->priv->current_station = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]