add_assignment: don't crash if assignment isn't found
add_assignment previously didn't handle the case where an existing
config assignment was not found, and segfaulted. Fix that by inserting
brand-new assignments at the end of the config list.
@@ -385,6 +385,12 @@ add_assignment(char **lines, const char *varname, const char *fmt, ...)
iinsert = isrc;
}
+ if (iinsert < 0)
+ {
+ /* No assignment found? Insert at the end. */
+ iinsert = isrc;
+ }
+
/* Build assignment. */
va_start(args, fmt);
if (superseded)
