Fix corner case when using fr_cursor_remove and fr_cursor_next_by_da together
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 23 May 2014 13:49:49 +0000 (14:49 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 23 May 2014 14:03:23 +0000 (15:03 +0100)
src/lib/cursor.c

index 6602047..39b9f9e 100644 (file)
@@ -265,6 +265,9 @@ VALUE_PAIR *fr_cursor_remove(vp_cursor_t *cursor)
        *last = vp->next;
        vp->next = NULL;
 
+       /* Fixup cursor->found if we removed the VP it was referring to */
+       if (vp == cursor->found) cursor->found = *last;
+
        return vp;
 }