[tracker/tracker-0.16] tracker-priority-queue: Check segments array bounds in peek function



commit e168927a63420802feeff1c8377a3146e10a5349
Author: Jonatan PĂ„lsson <jonatan palsson pelagicore com>
Date:   Thu Sep 12 10:20:25 2013 +0200

    tracker-priority-queue: Check segments array bounds in peek function
    
    Failing to do this will cause indexing outside the bounds of the array
    when the priority queue is empty.

 src/libtracker-miner/tracker-priority-queue.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-priority-queue.c b/src/libtracker-miner/tracker-priority-queue.c
index 43ae286..c360219 100644
--- a/src/libtracker-miner/tracker-priority-queue.c
+++ b/src/libtracker-miner/tracker-priority-queue.c
@@ -316,7 +316,7 @@ tracker_priority_queue_peek (TrackerPriorityQueue *queue,
 {
        g_return_val_if_fail (queue != NULL, NULL);
 
-       if (priority_out) {
+       if (priority_out && queue->segments->len > 0) {
                PrioritySegment *segment;
 
                segment = &g_array_index (queue->segments, PrioritySegment, 0);


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