Plug some leaks

This commit is contained in:
Roy Marples 2007-09-24 09:07:00 +00:00
parent 7a2507c52f
commit 495690ea5e
3 changed files with 17 additions and 23 deletions

View File

@ -341,9 +341,8 @@ void rc_set_service_daemon (const char *service, const char *exec,
oldfile = ffile;
}
}
if (ffile)
free (ffile);
free (files);
free (ffile);
rc_strlist_free (files);
}
/* Now store our daemon info */
@ -413,7 +412,7 @@ bool rc_service_started_daemon (const char *service, const char *exec,
if (retval)
break;
}
free (files);
rc_strlist_free (files);
}
free (mexec);

View File

@ -230,7 +230,7 @@ static char **find_mounts (struct args *args)
# error "Operating system not supported!"
#endif
static regex_t *get_regex (char *string)
static regex_t *get_regex (const char *string)
{
regex_t *reg = rc_xmalloc (sizeof (regex_t));
int result;
@ -279,6 +279,8 @@ int mountinfo (int argc, char **argv)
#define DO_REG(_var) \
if (_var) free (_var); \
_var = get_regex (optarg);
#define REG_FREE(_var) \
if (_var) { regfree (_var); free (_var); }
memset (&args, 0, sizeof (struct args));
args.mount_type = mount_to;
@ -333,18 +335,12 @@ int mountinfo (int argc, char **argv)
nodes = find_mounts (&args);
if (args.fstype_regex)
regfree (args.fstype_regex);
if (args.skip_fstype_regex)
regfree (args.skip_fstype_regex);
if (args.node_regex)
regfree (args.node_regex);
if (args.skip_node_regex)
regfree (args.skip_node_regex);
if (args.options_regex)
regfree (args.options_regex);
if (args.skip_options_regex)
regfree (args.skip_options_regex);
REG_FREE (args.fstype_regex);
REG_FREE (args.skip_fstype_regex);
REG_FREE (args.node_regex);
REG_FREE (args.skip_node_regex);
REG_FREE (args.options_regex);
REG_FREE (args.skip_options_regex);
rc_strlist_reverse (nodes);
@ -360,10 +356,8 @@ int mountinfo (int argc, char **argv)
}
rc_strlist_free (nodes);
if (point_regex)
regfree (point_regex);
if (skip_point_regex)
regfree (skip_point_regex);
REG_FREE (point_regex);
REG_FREE (skip_point_regex);
exit (result);
}

View File

@ -1140,8 +1140,9 @@ int main (int argc, char **argv)
CHAR_FREE (tmp);
} else {
/* Store our list of coldplugged services */
rc_strlist_join (&coldplugged_services,
rc_ls_dir (RC_SVCDIR_COLDPLUGGED, RC_LS_INITD));
tmplist = rc_ls_dir (RC_SVCDIR_COLDPLUGGED, RC_LS_INITD);
rc_strlist_join (&coldplugged_services, tmplist);
rc_strlist_free (tmplist);
if (strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 &&
strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0)