commit 7c3700015d907a650b876d543fe28407f8b9b5ea
parent 42af2efcf5845f8c892c83a979e1adf262a1bff1
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Thu, 20 May 2021 15:49:04 -0700
Allow item_seek to be given a NULL item
This was the cause of invalid memory access in the findnum function.
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/queue.c b/queue.c
@@ -77,6 +77,8 @@ item_pos(struct item *(*incr)(struct item *), struct item *item)
struct item *
item_seek(struct item *(*incr)(struct item *), struct item *item, unsigned int n)
{
+ if (item == NULL)
+ return NULL;
while (n-- && (item = incr(item)))
;
return item;