[rhythmbox] audioscrobbler: fix potential segfault when downloading image
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: fix potential segfault when downloading image
- Date: Tue, 21 Sep 2010 10:49:25 +0000 (UTC)
commit e460106c8fb13aeb33ffe9b9c923b7ae951c872f
Author: Jamie Nicol <jamie thenicols net>
Date: Thu Jun 24 22:33:53 2010 +0100
audioscrobbler: fix potential segfault when downloading image
check that arrays of user data are not null before checking for element
which matches downloaded image.
plugins/audioscrobbler/rb-audioscrobbler-user.c | 50 ++++++++++++++---------
1 files changed, 30 insertions(+), 20 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-user.c b/plugins/audioscrobbler/rb-audioscrobbler-user.c
index 35013cc..2c15c06 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-user.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-user.c
@@ -1551,36 +1551,46 @@ rb_audioscrobbler_user_image_download_cb (GObject *source_object, GAsyncResult *
0, data);
} else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_TRACK) {
int i;
- for (i = 0; i < user->priv->recent_tracks->len; i++) {
- if (g_ptr_array_index (user->priv->recent_tracks, i) == data) {
- g_signal_emit (user, rb_audioscrobbler_user_signals[RECENT_TRACKS_UPDATED],
- 0, user->priv->recent_tracks);
+ if (user->priv->recent_tracks != NULL) {
+ for (i = 0; i < user->priv->recent_tracks->len; i++) {
+ if (g_ptr_array_index (user->priv->recent_tracks, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[RECENT_TRACKS_UPDATED],
+ 0, user->priv->recent_tracks);
+ }
}
}
- for (i = 0; i < user->priv->top_tracks->len; i++) {
- if (g_ptr_array_index (user->priv->top_tracks, i) == data) {
- g_signal_emit (user, rb_audioscrobbler_user_signals[TOP_TRACKS_UPDATED],
- 0, user->priv->top_tracks);
+ if (user->priv->top_tracks != NULL) {
+ for (i = 0; i < user->priv->top_tracks->len; i++) {
+ if (g_ptr_array_index (user->priv->top_tracks, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[TOP_TRACKS_UPDATED],
+ 0, user->priv->top_tracks);
+ }
}
}
- for (i = 0; i < user->priv->loved_tracks->len; i++) {
- if (g_ptr_array_index (user->priv->loved_tracks, i) == data) {
- g_signal_emit (user, rb_audioscrobbler_user_signals[LOVED_TRACKS_UPDATED],
- 0, user->priv->loved_tracks);
+ if (user->priv->loved_tracks != NULL) {
+ for (i = 0; i < user->priv->loved_tracks->len; i++) {
+ if (g_ptr_array_index (user->priv->loved_tracks, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[LOVED_TRACKS_UPDATED],
+ 0, user->priv->loved_tracks);
+ }
}
}
} else if (data->type == RB_AUDIOSCROBBLER_USER_DATA_TYPE_ARTIST) {
int i;
- for (i = 0; i < user->priv->top_artists->len; i++) {
- if (g_ptr_array_index (user->priv->top_artists, i) == data) {
- g_signal_emit (user, rb_audioscrobbler_user_signals[TOP_ARTISTS_UPDATED],
- 0, user->priv->top_artists);
+ if (user->priv->top_artists != NULL) {
+ for (i = 0; i < user->priv->top_artists->len; i++) {
+ if (g_ptr_array_index (user->priv->top_artists, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[TOP_ARTISTS_UPDATED],
+ 0, user->priv->top_artists);
+ }
}
}
- for (i = 0; i < user->priv->recommended_artists->len; i++) {
- if (g_ptr_array_index (user->priv->recommended_artists, i) == data) {
- g_signal_emit (user, rb_audioscrobbler_user_signals[RECOMMENDED_ARTISTS_UPDATED],
- 0, user->priv->recommended_artists);
+ if (user->priv->recommended_artists != NULL) {
+ for (i = 0; i < user->priv->recommended_artists->len; i++) {
+ if (g_ptr_array_index (user->priv->recommended_artists, i) == data) {
+ g_signal_emit (user, rb_audioscrobbler_user_signals[RECOMMENDED_ARTISTS_UPDATED],
+ 0, user->priv->recommended_artists);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]