[rygel] core: Safer slicing of search results
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] core: Safer slicing of search results
- Date: Mon, 9 Nov 2009 18:47:01 +0000 (UTC)
commit 8af1dffb2ecb0b7fa7e237c8d4057d81db3ec5b3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Nov 5 18:40:21 2009 +0200
core: Safer slicing of search results
src/rygel/rygel-media-container.vala | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-media-container.vala b/src/rygel/rygel-media-container.vala
index 0d1691f..8f05b2c 100644
--- a/src/rygel/rygel-media-container.vala
+++ b/src/rygel/rygel-media-container.vala
@@ -136,15 +136,18 @@ public abstract class Rygel.MediaContainer : MediaObject {
// See if we need to slice the results
if (total_matches > 0 && (offset != 0 || max_count != 0)) {
+ uint start;
uint stop;
+ start = offset.clamp (0, total_matches - 1);
+
if (max_count != 0) {
- stop = offset + max_count;
+ stop = start + max_count;
} else {
stop = total_matches - 1;
}
- return result.slice ((int) offset, (int) stop);
+ return result.slice ((int) start, (int) stop);
} else {
return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]