[rygel] tracker: Clamp the index and offset



commit 55dbc78c1dbc77defffbc016b202661b19e257ce
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jun 24 14:43:10 2009 +0300

    tracker: Clamp the index and offset
    
    Without this, Rygel was crashing because of tracker plugin passing
    invalid params to List.slice().

 .../tracker/rygel-tracker-root-container.vala      |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-root-container.vala b/src/plugins/tracker/rygel-tracker-root-container.vala
index a008449..7f65f9f 100644
--- a/src/plugins/tracker/rygel-tracker-root-container.vala
+++ b/src/plugins/tracker/rygel-tracker-root-container.vala
@@ -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,



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