If we previously inserted a value pair, with no next pointer, and iterated to the end of the list, then inserted another vp with a next pointer, pairnext would return NULL, even though there were more value pairs available.
if (!*cursor->first) {
*cursor->first = add;
cursor->current = add;
- cursor->next = cursor->current->next;
return;
}
cursor->current = add;
}
+ /*
+ * If there's no next cursor, and the pair we just inserted has additional
+ * linked pairs, we need to set next to be the next VP in the list.
+ */
+ if (!cursor->next) {
+ cursor->next = add->next;
+ }
+
cursor->last->next = add;
}