tracker: Clamp the index and offset
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 24 Jun 2009 11:43:10 +0000 (14:43 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 24 Jun 2009 11:43:10 +0000 (14:43 +0300)
Without this, Rygel was crashing because of tracker plugin passing
invalid params to List.slice().

src/plugins/tracker/rygel-tracker-root-container.vala

index a008449..7f65f9f 100644 (file)
@@ -59,10 +59,11 @@ public class Rygel.TrackerRootContainer : MediaContainer {
                                        uint               max_count,
                                        Cancellable?       cancellable,
                                        AsyncReadyCallback callback) {
-        uint stop = offset + max_count;
-
+        uint start = offset.clamp (0, this.child_count - 1);
+        uint stop = start + max_count;
         stop = stop.clamp (0, this.child_count);
-        var children = this.categories.slice ((int) offset, (int) stop);
+
+        var children = this.categories.slice ((int) start, (int) stop);
 
         var res = new Rygel.SimpleAsyncResult<Gee.List<MediaObject>> (
                                         this,