From a4f9eb699b915c90ac93a4a9af4de5456085c26c Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 21 Mar 2008 20:02:10 +0000 Subject: Fix some crashers in a prefix with few services. --- src/rc/rc.c | 10 +++++++--- src/rc/runscript.c | 11 ++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/rc/rc.c b/src/rc/rc.c index 7b3d901..499e0dc 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -1145,9 +1145,13 @@ int main(int argc, char **argv) } } - if (coldplugged_services) - TAILQ_FOREACH(service, coldplugged_services, entries) - rc_stringlist_addu(start_services, service->value); + if (coldplugged_services) { + if (start_services) { + TAILQ_FOREACH(service, coldplugged_services, entries) + rc_stringlist_addu(start_services, service->value); + } else + start_services = coldplugged_services; + } } /* Save our softlevel now */ diff --git a/src/rc/runscript.c b/src/rc/runscript.c index d450004..6174615 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -1255,12 +1255,13 @@ int runscript(int argc, char **argv) runlevel, depoptions); rc_stringlist_free(tmplist); tmplist = NULL; - TAILQ_FOREACH(svc, services, entries) - printf("%s ", svc->value); - if (TAILQ_FIRST(services)) + if (services) { + TAILQ_FOREACH(svc, services, entries) + printf("%s ", svc->value); printf ("\n"); - rc_stringlist_free(services); - services = NULL; + rc_stringlist_free(services); + services = NULL; + } } else if (strcmp (optarg, "status") == 0) { RC_SERVICE r = svc_status(); retval = (int) r; -- cgit v1.2.3