Skip to content

Commit

Permalink
Fix corner case where cursor.next wasn't fixed up correctly on fr_cur…
Browse files Browse the repository at this point in the history
…sor_insert
  • Loading branch information
arr2036 committed Mar 20, 2015
1 parent f60637e commit 6e35c86
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/cursor.c
Expand Up @@ -336,13 +336,16 @@ void fr_cursor_insert(vp_cursor_t *cursor, VALUE_PAIR *vp)
if (!cursor->current) cursor->current = vp;

/*
* 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.
* Add the VALUE_PAIR onto the end of the list
*/
if (!cursor->next) cursor->next = vp->next;

cursor->last->next = vp;
cursor->last = vp; /* Wind it forward a little more */

/*
* If there's no next cursor and the new current, points to another
* VALUE_PAIR, fix that up.
*/
if (!cursor->next) cursor->next = cursor->current->next;
}

/** Merges multiple VALUE_PAIR into the cursor
Expand Down

0 comments on commit 6e35c86

Please sign in to comment.