util: fix segfault in prioq_remove() with empty Prioq object

This commit is contained in:
Yu Watanabe
2018-10-16 22:27:30 +09:00
parent d13b5f5a85
commit cd86deefa1
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -211,6 +211,9 @@ _pure_ static struct prioq_item* find_item(Prioq *q, void *data, unsigned *idx)
assert(q);
if (q->n_items <= 0)
return NULL;
if (idx) {
if (*idx == PRIOQ_IDX_NULL ||
*idx > q->n_items)