At the end of the parsing of a SPOE agent configuration file, the messages
of the file are moved to the agent message list with a manual splice.
However, this is only correct when the file defines at least one
"spoe-message" section. With an empty list, the manual splice will corrupt
the agent message list.
Replace the manual splice with LIST_SPLICE(), which does nothing with an
empty source list. This fixes the bug and this avoids to deal with list
pointers manually.
The regression was introduced by the commit
11610f3 ("MEDIUM: spoe: Parse
new "spoe-group" section in SPOE config file").
The patch must be backported to all supported versions.
finish:
/* move curmsgs to the agent message list */
- curmsgs.n->p = &curagent->messages;
- curmsgs.p->n = &curagent->messages;
- curagent->messages = curmsgs;
+ LIST_SPLICE(&curagent->messages, &curmsgs);
LIST_INIT(&curmsgs);
conf->id = strdup(engine ? engine : curagent->id);