Misc fixes, plugged a memory leak in runscript.c and use va_copy to avoid nasty segfaults

This commit is contained in:
Roy Marples
2007-04-06 01:04:07 +00:00
parent 308042c87b
commit 657be65340
11 changed files with 75 additions and 45 deletions

View File

@@ -1013,19 +1013,22 @@ int main (int argc, char **argv)
/* Unless we would use a different config file */
if (found)
{
int len;
if (! newlevel)
continue;
tmp = rc_xmalloc (strlen (service) + strlen (runlevel) + 2);
sprintf (tmp, "%s.%s", service, runlevel);
len = strlen (service) + strlen (runlevel) + 2;
tmp = rc_xmalloc (sizeof (char *) * len);
snprintf (tmp, len, "%s.%s", service, runlevel);
conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
found = rc_exists (conf);
CHAR_FREE (conf);
CHAR_FREE (tmp);
if (! found)
{
tmp = rc_xmalloc (strlen (service) + strlen (newlevel) + 2);
sprintf (tmp, "%s.%s", service, newlevel);
len = strlen (service) + strlen (newlevel) + 2;
tmp = rc_xmalloc (sizeof (char *) * len);
snprintf (tmp, len, "%s.%s", service, newlevel);
conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
found = rc_exists (conf);
CHAR_FREE (conf);