chiark / gitweb /
bus: properly handle if new objects are installed in the node tree while we are dispa...
[elogind.git] / src / shared / prioq.c
index a2205719b47bf6dc1dfc01ccf52ec02a1af6438d..537befc623a1554bd4b57bb115ca223bacddbbb4 100644 (file)
@@ -211,13 +211,14 @@ static void remove_item(Prioq *q, struct prioq_item *i) {
         }
 }
 
-static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) {
+_pure_ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx) {
         struct prioq_item *i;
 
         assert(q);
 
         if (idx) {
-                if (*idx > q->n_items)
+                if (*idx == PRIOQ_IDX_NULL ||
+                    *idx > q->n_items)
                         return NULL;
 
                 i = q->items + *idx;