FreeRADIUS/freeradius-server — pull request #809 by Feh (2014-10-09 11:01:18+00:00)
Title: pairadd: Don't add a VP if it's already present

In the 3.0 code base, pairmake() will already do a pairadd()
automatically. If an old code base (e.g. modules originally written for
FreeRADIUS 2.x) uses pairmake() and then pairadd() explicitly, this will
add the VP *twice*, thus creating a cyclic list structure, e.g.:

A->next == B;
B->next == B;
B->next == B;
B->next == B;
...

This makes any function that walks all value pairs end up eating 100%
CPU.

Since VPs are added at the end of the list, we can simply stop
traversing the list and return silently in case the VP is already
present.