diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c index 5c7e3660..25d230cd 100644 --- a/src/librc/librc-misc.c +++ b/src/librc/librc-misc.c @@ -203,6 +203,9 @@ char *rc_config_value(RC_STRINGLIST *list, const char *entry) RC_STRING *line; char *p; + if (!list) + return NULL; + TAILQ_FOREACH(line, list, entries) { p = strchr(line->value, '='); if (p && diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c index e802ee4f..42d9e532 100644 --- a/src/rc/rc-misc.c +++ b/src/rc/rc-misc.c @@ -79,20 +79,24 @@ char *rc_conf_value(const char *setting) if (exists(RC_CONF_OLD)) { old = rc_config_load(RC_CONF_OLD); if (old) { - TAILQ_CONCAT(rc_conf, old, entries); - free(old); + if (rc_conf) { + TAILQ_CONCAT(rc_conf, old, entries); + free(old); + } else + rc_conf = old; } } /* Convert old uppercase to lowercase */ - TAILQ_FOREACH(s, rc_conf, entries) { - p = s->value; - while (p && *p && *p != '=') { - if (isupper((int) *p)) - *p = tolower((int) *p); - p++; + if (rc_conf) + TAILQ_FOREACH(s, rc_conf, entries) { + p = s->value; + while (p && *p && *p != '=') { + if (isupper((int) *p)) + *p = tolower((int) *p); + p++; + } } - } } return rc_config_value(rc_conf, setting);