From 2a0a4b7fa63c0d24908118a2c01c2bfc9da613ce Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Wed, 14 Mar 2012 17:01:42 +0100 Subject: [PATCH] core: Do not abort on invalid indices Check if the thumbnail or subtitle a client requestes actually exists. Otherwise libgee just aborts. https://bugzilla.gnome.org/show_bug.cgi?id=672048 --- src/rygel/rygel-http-get.vala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/rygel/rygel-http-get.vala b/src/rygel/rygel-http-get.vala index 9e5f942..a7ca2ef 100644 --- a/src/rygel/rygel-http-get.vala +++ b/src/rygel/rygel-http-get.vala @@ -94,9 +94,10 @@ internal class Rygel.HTTPGet : HTTPRequest { this.thumbnail = music.album_art; } else if (this.item is VisualItem) { var visual = this.item as VisualItem; - - this.thumbnail = visual.thumbnails.get - (this.uri.thumbnail_index); + if (visual.thumbnails.size >= this.uri.thumbnail_index) { + this.thumbnail = visual.thumbnails.get + (this.uri.thumbnail_index); + } } else { throw new HTTPRequestError.NOT_FOUND ("No Thumbnail available for item '%s", @@ -109,8 +110,11 @@ internal class Rygel.HTTPGet : HTTPRequest { this.item.id); } - this.subtitle = (this.item as VideoItem).subtitles.get - (this.uri.subtitle_index); + var video = this.item as VideoItem; + + if (this.uri.subtitle_index <= video.subtitles.size) { + this.subtitle = video.subtitles.get (this.uri.subtitle_index); + } } } -- 2.7.4