[rygel] core: Do not abort on invalid indices



commit 2a0a4b7fa63c0d24908118a2c01c2bfc9da613ce
Author: Jens Georg <mail jensge org>
Date:   Wed Mar 14 17:01:42 2012 +0100

    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 files 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);
+            }
         }
     }
 



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